﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DAL;
using CommontLibrary;
using System.Xml;
using System.Xml.Xsl;
public partial class UserControl_Reports_loadReport23STruong : System.Web.UI.UserControl
{
    #region "Member variables"
        DALevel objLevel;
        DAQuyen objQuyen;
        DAHocVienLV2 objHocVienLV2;
        DAHocVienLV3LV5 objHocVienLV3LV5;
        DAHocVienLV6LV8 objHocVienLV6LV8;
        DAHocVien objHocVien;
        DANguoidung objNguoidung;
        DATrangThai objTrangThai;
        DATrangThaiGoi objTrangThaiGoi;
        DAReport objReport;
        DANguon objNguon;
        DATruong objTruong;
        int intTrangThaiGoi1 = 1;
        string intTrangThaiGoi2 = "2,3,4,5,6,7";
        int intTrangThaiGoi3 = 8;
        DataTable m_dtDataReport1 = new DataTable();
        #region "Sum Bang 1"
        //SumView Bang 1
        int intsum1 = 0;
        int intsum2 = 0;
        int intsum3 = 0;
        int intsum4 = 0;
        int intsum5A = 0;
        int intsum5B = 0;
        int intsum6 = 0;
        int intsum7 = 0;
        int intsum8 = 0;
        int intsum9 = 0;
        //SumT Bang 1
        int intsumT1 = 0;
        int intsumT2 = 0;
        int intsumT3 = 0;
        int intsumT4 = 0;
        int intsumT5A = 0;
        int intsumT5B = 0;
        int intsumT6 = 0;
        int intsumT7 = 0;
        int intsumT8 = 0;
        int intsumT9 = 0;
        //SumLx1 Bang 1
        int intsumLx11 = 0;
        int intsumLx12 = 0;
        int intsumLx13 = 0;
        int intsumLx14 = 0;
        int intsumLx15A = 0;
        int intsumLx15B = 0;
        int intsumLx16 = 0;
        int intsumLx17 = 0;
        int intsumLx18 = 0;
        int intsumLx19 = 0;
        //SumLx2 Bang 1
        int intsumLx21 = 0;
        int intsumLx22 = 0;
        int intsumLx23 = 0;
        int intsumLx24 = 0;
        int intsumLx25A = 0;
        int intsumLx25B = 0;
        int intsumLx26 = 0;
        int intsumLx27 = 0;
        int intsumLx28 = 0;
        int intsumLx29 = 0;
        //SumLx3 Bang 1
        int intsumLx31 = 0;
        int intsumLx32 = 0;
        int intsumLx33 = 0;
        int intsumLx34 = 0;
        int intsumLx35A = 0;
        int intsumLx35B = 0;
        int intsumLx36 = 0;
        int intsumLx37 = 0;
        int intsumLx38 = 0;
        int intsumLx39 = 0;

        #endregion
        #region "Sum Bang 2"
        //SumView Bang 2
        int intsum_Bang2_1 = 0;
        int intsum_Bang2_2 = 0;
        int intsum_Bang2_3 = 0;
        int intsum_Bang2_4 = 0;
        int intsum_Bang2_5A = 0;
        int intsum_Bang2_5B = 0;
        int intsum_Bang2_6 = 0;
        int intsum_Bang2_7 = 0;
        int intsum_Bang2_8 = 0;
        int intsum_Bang2_9 = 0;
        //SumT Bang 2
        int intsumT_Bang2_1 = 0;
        int intsumT_Bang2_2 = 0;
        int intsumT_Bang2_3 = 0;
        int intsumT_Bang2_4 = 0;
        int intsumT_Bang2_5A = 0;
        int intsumT_Bang2_5B = 0;
        int intsumT_Bang2_6 = 0;
        int intsumT_Bang2_7 = 0;
        int intsumT_Bang2_8 = 0;
        int intsumT_Bang2_9 = 0;
        //SumLx1 Bang 2
        int intsumLx1_Bang2_1 = 0;
        int intsumLx1_Bang2_2 = 0;
        int intsumLx1_Bang2_3 = 0;
        int intsumLx1_Bang2_4 = 0;
        int intsumLx1_Bang2_5A = 0;
        int intsumLx1_Bang2_5B = 0;
        int intsumLx1_Bang2_6 = 0;
        int intsumLx1_Bang2_7 = 0;
        int intsumLx1_Bang2_8 = 0;
        int intsumLx1_Bang2_9 = 0;
        //SumLx2 Bang 2
        int intsumLx2_Bang2_1 = 0;
        int intsumLx2_Bang2_2 = 0;
        int intsumLx2_Bang2_3 = 0;
        int intsumLx2_Bang2_4 = 0;
        int intsumLx2_Bang2_5A = 0;
        int intsumLx2_Bang2_5B = 0;
        int intsumLx2_Bang2_6 = 0;
        int intsumLx2_Bang2_7 = 0;
        int intsumLx2_Bang2_8 = 0;
        int intsumLx2_Bang2_9 = 0;
        //SumLx3 Bang 2
        int intsumLx3_Bang2_1 = 0;
        int intsumLx3_Bang2_2 = 0;
        int intsumLx3_Bang2_3 = 0;
        int intsumLx3_Bang2_4 = 0;
        int intsumLx3_Bang2_5A = 0;
        int intsumLx3_Bang2_5B = 0;
        int intsumLx3_Bang2_6 = 0;
        int intsumLx3_Bang2_7 = 0;
        int intsumLx3_Bang2_8 = 0;
        int intsumLx3_Bang2_9 = 0;

        #endregion
        #region "Sum Bang 3"
        //SumView Bang 3
        int intsum_Bang3_1 = 0;
        int intsum_Bang3_2 = 0;
        int intsum_Bang3_3 = 0;
        int intsum_Bang3_4 = 0;
        int intsum_Bang3_5A = 0;
        int intsum_Bang3_5B= 0;
        int intsum_Bang3_6 = 0;
        int intsum_Bang3_7 = 0;
        int intsum_Bang3_8 = 0;
        int intsum_Bang3_9 = 0;
        //SumSL Bang 3
        int intsumSL_Bang3_1 = 0;
        int intsumSL_Bang3_2 = 0;
        int intsumSL_Bang3_3 = 0;
        int intsumSL_Bang3_4 = 0;
        int intsumSL_Bang3_5A = 0;
        int intsumSL_Bang3_5B = 0;
        int intsumSL_Bang3_6 = 0;
        int intsumSL_Bang3_7 = 0;
        int intsumSL_Bang3_8 = 0;
        int intsumSL_Bang3_9 = 0;
        //Sum So ton chua lam Bang 3
        int intsumSTCL_Bang3_1 = 0;
        int intsumSTCL_Bang3_2 = 0;
        int intsumSTCL_Bang3_3 = 0;
        int intsumSTCL_Bang3_4 = 0;
        int intsumSTCL_Bang3_5A = 0;
        int intsumSTCL_Bang3_5B = 0;
        int intsumSTCL_Bang3_6 = 0;
        int intsumSTCL_Bang3_7 = 0;
        int intsumSTCL_Bang3_8 = 0;
        int intsumSTCL_Bang3_9 = 0;
        //Sum so da lam chua len level Bang 3
        int intsumCLLV_Bang3_1 = 0;
        int intsumCLLV_Bang3_2 = 0;
        int intsumCLLV_Bang3_3 = 0;
        int intsumCLLV_Bang3_4 = 0;
        int intsumCLLV_Bang3_5A = 0;
        int intsumCLLV_Bang3_5B = 0;
        int intsumCLLV_Bang3_6 = 0;
        int intsumCLLV_Bang3_7 = 0;
        int intsumCLLV_Bang3_8 = 0;
        int intsumCLLV_Bang3_9 = 0;
        //Sum So khong nen lam nua Bang 3
        int intsumKNL_Bang3_1 = 0;
        int intsumKNL_Bang3_2 = 0;
        int intsumKNL_Bang3_3 = 0;
        int intsumKNL_Bang3_4 = 0;
        int intsumKNL_Bang3_5A = 0;
        int intsumKNL_Bang3_5B = 0;
        int intsumKNL_Bang3_6 = 0;
        int intsumKNL_Bang3_7 = 0;
        int intsumKNL_Bang3_8 = 0;
        int intsumKNL_Bang3_9 = 0;

        #endregion
        #region "Phan tram bang 2"
        //Lx1
        Decimal decPercentLx1L1 = 0;
        Decimal decPercentLx1L2 = 0;
        Decimal decPercentLx1L3 = 0;
        Decimal decPercentLx1L4 = 0;
        Decimal decPercentLx1L5A = 0;
        Decimal decPercentLx1L5B = 0;
        Decimal decPercentLx1L6 = 0;
        Decimal decPercentLx1L7 = 0;
        Decimal decPercentLx1L8 = 0;
        Decimal decPercentLx1L9 = 0;
        //Lx3
        Decimal decPercentLx31 = 0;
        Decimal decPercentLx32 = 0;
        Decimal decPercentLx33 = 0;
        Decimal decPercentLx34 = 0;
        Decimal decPercentLx35A = 0;
        Decimal decPercentLx35B = 0;
        Decimal decPercentLx36 = 0;
        Decimal decPercentLx37 = 0;
        Decimal decPercentLx38 = 0;
        Decimal decPercentLx39 = 0;
        //Lx2
        Decimal decPercentLx21 = 0;
        Decimal decPercentLx22 = 0;
        Decimal decPercentLx23 = 0;
        Decimal decPercentLx24 = 0;
        Decimal decPercentLx25A = 0;
        Decimal decPercentLx25B = 0;
        Decimal decPercentLx26 = 0;
        Decimal decPercentLx27 = 0;
        Decimal decPercentLx28 = 0;
        Decimal decPercentLx29 = 0;
        #endregion
        #region "Phan tram bang 1"       
        //Lx1
        Decimal decPercentReportLx1L1 = 0;
        Decimal decPercentReportLx1L2 = 0;
        Decimal decPercentReportLx1L3 = 0;
        Decimal decPercentReportLx1L4 = 0;
        Decimal decPercentReportLx1L5A = 0;
        Decimal decPercentReportLx1L5B = 0;
        Decimal decPercentReportLx1L6 = 0;
        Decimal decPercentReportLx1L7 = 0;
        Decimal decPercentReportLx1L8 = 0;
        Decimal decPercentReportLx1L9 = 0;
        //Lx2
        Decimal decPercentReportLx2L1 = 0;
        Decimal decPercentReportLx2L2 = 0;
        Decimal decPercentReportLx2L3 = 0;
        Decimal decPercentReportLx2L4 = 0;
        Decimal decPercentReportLx2L5A = 0;
        Decimal decPercentReportLx2L5B = 0;
        Decimal decPercentReportLx2L6 = 0;
        Decimal decPercentReportLx2L7 = 0;
        Decimal decPercentReportLx2L8 = 0;
        Decimal decPercentReportLx2L9 = 0;

        //L3
        Decimal decPercentReportLx3L1 = 0;
        Decimal decPercentReportLx3L2 = 0;
        Decimal decPercentReportLx3L3 = 0;
        Decimal decPercentReportLx3L4 = 0;
        Decimal decPercentReportLx3L5A = 0;
        Decimal decPercentReportLx3L5B = 0;
        Decimal decPercentReportLx3L6 = 0;
        Decimal decPercentReportLx3L7 = 0;
        Decimal decPercentReportLx3L8 = 0;
        Decimal decPercentReportLx3L9 = 0;
        
        //Tong3
        int intCRM1 = 0;
        int intCRM2 = 0;
        int intCRM3 = 0;
        int intCRM4 = 0;
        int intCRM5A = 0;
        int intCRM5B = 0;
        int intCRM6 = 0;
        int intCRM7 = 0;
        int intCRM8 = 0;
        int intCRM9 = 0;
        #endregion
 #endregion
    #region "Private method"
        //load tu bang Hocvien
        #region "Bang 2"
        
        public void loadLevelView(ref string strTable,string strText,int intNguoiDungID,int NguonID,int TruongID)
        {
            #region "View Top"
                //---------------------------------------------------------- Dong tren cung -------------------------------
                int intL1 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 1,NguonID,TruongID);
                int intL2 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 2, NguonID, TruongID);
                int intL3 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 3, NguonID, TruongID);
                int intL4 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 4, NguonID, TruongID);
                int intL5A = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 5, NguonID, TruongID);
                int intL5B = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 6, NguonID, TruongID);
                int intL6 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 7, NguonID, TruongID);
                int intL7 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 8, NguonID, TruongID);
                int intL8 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 9, NguonID, TruongID);
                int intL9 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 10, NguonID, TruongID);
                //--Luu gia tri tong dong cuoi cung cua bang
                intsum_Bang2_1 += intL1;
                intsum_Bang2_2 += intL2;
                intsum_Bang2_3 += intL3;
                intsum_Bang2_4 += intL4;
                intsum_Bang2_5A += intL5A;
                intsum_Bang2_5B += intL5B;
                intsum_Bang2_6 += intL6;
                intsum_Bang2_7 += intL7;
                intsum_Bang2_8 += intL8;
                intsum_Bang2_9 += intL9;

                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + strText + "</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intL1.ToString() + "</td>";//L1
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intL2.ToString() + "</td>";//L2
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intL3.ToString() + "</td>";//L3
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intL4.ToString() + "</td>";//L4
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intL5A.ToString() + "</td>";//L5A
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intL5B.ToString() + "</td>";//L5B
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intL6.ToString() + "</td>";//L6
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intL7.ToString() + "</td>";//L7
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intL8.ToString() + "</td>";//L8
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intL9.ToString() + "</td>";//L9
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                strTable += "\n</tr>";
            #endregion
            #region "View So luong tong"
                //----------------------------------------------------------Số lượng tổng-------------------------------
                strTable += "\n<tr>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Số lượng tổng</td>";
                //Tong LV1
                int intTotalLv1 = intL1 + intL2 + intL3 + intL4 + intL5A + intL5B + intL6 + intL7 + intL8 + intL9;                  
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv1.ToString() + "</td>";//L1
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                //Tong LV2
                int intTotalLv2 = intTotalLv1 - intL1;
                int intTotalLv3 = intTotalLv2 - intL2;
                int intTotalLv4 = intTotalLv3 - intL3;
                int intTotalLv5A = intTotalLv4 - intL4;
                int intTotalLv5B = intTotalLv5A - intL5A;
                int intTotalLv6 = intTotalLv5B - intL5B;
                int intTotalLv7 = intTotalLv6 - intL6;
                int intTotalLv8 = intTotalLv7 - intL7;
                int intTotalLv9 = intTotalLv8 - intL8;
                //--Luu gia tri tong dong cuoi cung cua bang
                intsumT_Bang2_1 += intTotalLv1;
                intsumT_Bang2_2 += intTotalLv2;
                intsumT_Bang2_3 += intTotalLv3;
                intsumT_Bang2_4 += intTotalLv4;
                intsumT_Bang2_5A += intTotalLv5A;
                intsumT_Bang2_5B += intTotalLv5B;
                intsumT_Bang2_6 += intTotalLv6;
                intsumT_Bang2_7 += intTotalLv7;
                intsumT_Bang2_8 += intTotalLv8;
                intsumT_Bang2_9 += intTotalLv9;
                if (intTotalLv1 != 0)
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv2.ToString() + "</td>\n<td class='cssPercentReport'>" + Convert.ToInt32(intTotalLv2 * 100 / intTotalLv1).ToString() + "%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv3.ToString() + "</td>\n<td class='cssPercentReport'>" + Convert.ToInt32(intTotalLv3 * 100 / intTotalLv1).ToString() + "%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv4.ToString() + "</td>\n<td class='cssPercentReport'>" + Convert.ToInt32(intTotalLv4 * 100 / intTotalLv1).ToString() + "%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv5A.ToString() + "</td>\n<td class='cssPercentReport'>" + Convert.ToInt32(intTotalLv5A * 100 / intTotalLv1).ToString() + "%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv5B.ToString() + "</td>\n<td class='cssPercentReport'>" + Convert.ToInt32(intTotalLv5B * 100 / intTotalLv1).ToString() + "%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv6.ToString() + "</td>\n<td class='cssPercentReport'>" + Convert.ToInt32(intTotalLv6 * 100 / intTotalLv1).ToString() + "%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv7.ToString() + "</td>\n<td class='cssPercentReport'>" + Convert.ToInt32(intTotalLv7 * 100 / intTotalLv1).ToString() + "%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv8.ToString() + "</td>\n<td class='cssPercentReport'>" + Convert.ToInt32(intTotalLv8 * 100 / intTotalLv1).ToString() + "%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv9.ToString() + "</td>\n<td class='cssPercentReport'>" + Convert.ToInt32(intTotalLv9 * 100 / intTotalLv1).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv2.ToString() + "</td>\n<td class='cssPercentReport'>0%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv3.ToString() + "</td>\n<td class='cssPercentReport'>0%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv4.ToString() + "</td>\n<td class='cssPercentReport'>0%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv5A.ToString() + "</td>\n<td class='cssPercentReport'>0%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv5B.ToString() + "</td>\n<td class='cssPercentReport'>0%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv6.ToString() + "</td>\n<td class='cssPercentReport'>0%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv7.ToString() + "</td>\n<td class='cssPercentReport'>0%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv8.ToString() + "</td>\n<td class='cssPercentReport'>0%</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalLv9.ToString() + "</td>\n<td class='cssPercentReport'>0%</td>";
                }
                strTable += "\n</tr>";
            #endregion
            #region "View Lx1"
                //----------------------------------------------------------View Lx1-------------------------------
                strTable += "\n<tr>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Lx.1</td>";
                //LV1
                int intCountTrangThaiLV1 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 1, intTrangThaiGoi1, NguonID,TruongID);
                int intCountTrangThaiLV2 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 2, intTrangThaiGoi1, NguonID, TruongID);
                int intCountTrangThaiLV3 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 3, intTrangThaiGoi1, NguonID, TruongID);
                int intCountTrangThaiLV4 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 4, intTrangThaiGoi1, NguonID, TruongID);
                int intCountTrangThaiLV5A = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 5, intTrangThaiGoi1, NguonID, TruongID);
                int intCountTrangThaiLV5B = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 6, intTrangThaiGoi1, NguonID, TruongID);
                int intCountTrangThaiLV6 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 7, intTrangThaiGoi1, NguonID, TruongID);
                int intCountTrangThaiLV7 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 8, intTrangThaiGoi1, NguonID, TruongID);
                int intCountTrangThaiLV8 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 9, intTrangThaiGoi1, NguonID, TruongID);
                int intCountTrangThaiLV9 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 10, intTrangThaiGoi1, NguonID, TruongID);
                // Tinh tong cuoi cung
                intsumLx1_Bang2_1 += intCountTrangThaiLV1;
                intsumLx1_Bang2_2 += intCountTrangThaiLV2;
                intsumLx1_Bang2_3 += intCountTrangThaiLV3;
                intsumLx1_Bang2_4 +=intCountTrangThaiLV4;
                intsumLx1_Bang2_5A += intCountTrangThaiLV5A;
                intsumLx1_Bang2_5B +=intCountTrangThaiLV5B;
                intsumLx1_Bang2_6 +=intCountTrangThaiLV6;
                intsumLx1_Bang2_7 +=intCountTrangThaiLV7;
                intsumLx1_Bang2_8 +=intCountTrangThaiLV8;
                intsumLx1_Bang2_9 +=intCountTrangThaiLV9;
                //LV1 
                decPercentLx1L1 = 0;
                if (intCountTrangThaiLV1 != 0)
                {
                    decPercentLx1L1 = Math.Round((Decimal)(intCountTrangThaiLV1 * 100 / intL1), 0, MidpointRounding.AwayFromZero);
                }
                //LV2
                decPercentLx1L2 = 0;
                if (intCountTrangThaiLV2 != 0)
                {
                    decPercentLx1L2 = Math.Round((Decimal)(intCountTrangThaiLV2 * 100 / intL2), 0, MidpointRounding.AwayFromZero);
                }
                //LV3
                decPercentLx1L3 = 0;
                if (intCountTrangThaiLV3 != 0)
                {
                    decPercentLx1L3 = Math.Round((Decimal)(intCountTrangThaiLV3 * 100 / intL3), 0, MidpointRounding.AwayFromZero);
                }
                //LV4
                decPercentLx1L4 = 0;
                if (intCountTrangThaiLV4 != 0)
                {
                    decPercentLx1L4 = Math.Round((Decimal)(intCountTrangThaiLV4 * 100 / intL4), 0, MidpointRounding.AwayFromZero);
                }
                //LV5A
                decPercentLx1L5A = 0;
                if (intCountTrangThaiLV5A != 0)
                {
                    decPercentLx1L5A = Math.Round((Decimal)(intCountTrangThaiLV5A * 100 / intL5A), 0, MidpointRounding.AwayFromZero);
                }
                //LV5B
                decPercentLx1L5B = 0;
                if (intCountTrangThaiLV5B != 0)
                {
                    decPercentLx1L5B = Math.Round((Decimal)(intCountTrangThaiLV5B * 100 / intL5B), 0, MidpointRounding.AwayFromZero);
                }
                //LV6
                decPercentLx1L6 = 0;
                if (intCountTrangThaiLV6 != 0)
                {
                    decPercentLx1L6 = Math.Round((Decimal)(intCountTrangThaiLV6 * 100 / intL6), 0, MidpointRounding.AwayFromZero);
                }
                //LV7
                decPercentLx1L7 = 0;
                if (intCountTrangThaiLV7 != 0)
                {
                    decPercentLx1L7 = Math.Round((Decimal)(intCountTrangThaiLV7 * 100 / intL7), 0, MidpointRounding.AwayFromZero);
                }
                //LV8
                decPercentLx1L8 = 0;
                if (intCountTrangThaiLV8 != 0)
                {
                    decPercentLx1L8 = Math.Round((Decimal)(intCountTrangThaiLV8 * 100 / intL8), 0, MidpointRounding.AwayFromZero);
                }
                //LV9
                decPercentLx1L9 = 0;
                if (intCountTrangThaiLV9 != 0)
                {
                    decPercentLx1L9 = Math.Round((Decimal)(intCountTrangThaiLV9 * 100 / intL9), 0, MidpointRounding.AwayFromZero);
                }
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLV1.ToString() + "</td>";
                strTable += "\n<td class='cssPercentReport'>" + decPercentLx1L1.ToString() + "%</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLV2.ToString() + "</td>";//L2
                strTable += "\n<td class='cssPercentReport'>" + decPercentLx1L2.ToString() + "%</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLV3.ToString() + "</td>";//L3
                strTable += "\n<td class='cssPercentReport'>" + decPercentLx1L3.ToString() + "%</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLV4.ToString() + "</td>";//L4
                strTable += "\n<td class='cssPercentReport'>" + decPercentLx1L4.ToString() + "%</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLV5A.ToString() + "</td>";//L5A
                strTable += "\n<td class='cssPercentReport'>" + decPercentLx1L5A.ToString() + "%</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLV5B.ToString() + "</td>";//L5B
                strTable += "\n<td class='cssPercentReport'>" + decPercentLx1L5B.ToString() + "%</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLV6.ToString() + "</td>";//L6
                strTable += "\n<td class='cssPercentReport'>" + decPercentLx1L6.ToString() + "%</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLV7.ToString() + "</td>";//L7
                strTable += "\n<td class='cssPercentReport'>" + decPercentLx1L7.ToString() + "%</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLV8.ToString() + "</td>";//L8
                strTable += "\n<td class='cssPercentReport'>" + decPercentLx1L8.ToString() + "%</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLV9.ToString() + "</td>";//L8
                strTable += "\n<td class='cssPercentReport'>" + decPercentLx1L9.ToString() + "%</td>";
                strTable += "\n</tr>";
            #endregion
            #region "View Lx3"
                //----------------------------------------------------------View Lx3-------------------------------
                string strTableTemp3 = "\n<tr>";
                strTableTemp3 += "\n<td class='cssTitleReport' nowrap='nowrap'>Lx.3</td>";
                //LV3
                int intCountTrangThaiLX3LV1 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 1, intTrangThaiGoi3, NguonID, TruongID);
                int intCountTrangThaiLX3LV2 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 2, intTrangThaiGoi3, NguonID, TruongID);
                int intCountTrangThaiLX3LV3 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 3, intTrangThaiGoi3, NguonID, TruongID);
                int intCountTrangThaiLX3LV4 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 4, intTrangThaiGoi3, NguonID, TruongID);
                int intCountTrangThaiLX3LV5A = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 5, intTrangThaiGoi3, NguonID, TruongID);
                int intCountTrangThaiLX3LV5B = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 6, intTrangThaiGoi3, NguonID, TruongID);
                int intCountTrangThaiLX3LV6 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 7, intTrangThaiGoi3, NguonID, TruongID);
                int intCountTrangThaiLX3LV7 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 8, intTrangThaiGoi3, NguonID, TruongID);
                int intCountTrangThaiLX3LV8 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 9, intTrangThaiGoi3, NguonID, TruongID);
                int intCountTrangThaiLX3LV9 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 10, intTrangThaiGoi3, NguonID, TruongID);
                // Tinh tong cuoi cung
                intsumLx3_Bang2_1 += intCountTrangThaiLX3LV1;
                intsumLx3_Bang2_2 += intCountTrangThaiLX3LV2;
                intsumLx3_Bang2_3 += intCountTrangThaiLX3LV3;
                intsumLx3_Bang2_4 += intCountTrangThaiLX3LV4;
                intsumLx3_Bang2_5A += intCountTrangThaiLX3LV5A;
                intsumLx3_Bang2_5B += intCountTrangThaiLX3LV5B;
                intsumLx3_Bang2_6 += intCountTrangThaiLX3LV6;
                intsumLx3_Bang2_7 += intCountTrangThaiLX3LV7;
                intsumLx3_Bang2_8 += intCountTrangThaiLX3LV8;
                intsumLx3_Bang2_9 += intCountTrangThaiLX3LV9;

                decPercentLx31 = 0;
                if (intCountTrangThaiLX3LV1 != 0)
                {
                    decPercentLx31 = Math.Round((Decimal)(intCountTrangThaiLX3LV1 * 100 / intL1), 0, MidpointRounding.AwayFromZero);
                }
                //LV2
                decPercentLx32 = 0;
                if (intCountTrangThaiLX3LV2 != 0)
                {
                    decPercentLx32 = Math.Round((Decimal)(intCountTrangThaiLX3LV2 * 100 / intL2), 0, MidpointRounding.AwayFromZero);
                }
                //LV3
                decPercentLx33 = 0;
                if (intCountTrangThaiLX3LV3 != 0)
                {
                    decPercentLx33 = Math.Round((Decimal)(intCountTrangThaiLX3LV3 * 100 / intL3), 0, MidpointRounding.AwayFromZero);
                }
                //LV4
                decPercentLx34 = 0;
                if (intCountTrangThaiLX3LV4 != 0)
                {
                    decPercentLx34 = Math.Round((Decimal)(intCountTrangThaiLX3LV4 * 100 / intL4), 0, MidpointRounding.AwayFromZero);
                }
                //LV5A
                decPercentLx35A = 0;
                if (intCountTrangThaiLX3LV5A != 0)
                {
                    decPercentLx35A = Math.Round((Decimal)(intCountTrangThaiLX3LV5A * 100 / intL5A), 0, MidpointRounding.AwayFromZero);
                }
                //LV5B
                decPercentLx35B = 0;
                if (intCountTrangThaiLX3LV5B != 0)
                {
                    decPercentLx35B = Math.Round((Decimal)(intCountTrangThaiLX3LV5B * 100 / intL5B), 0, MidpointRounding.AwayFromZero);
                }
                //LV6
                decPercentLx36 = 0;
                if (intCountTrangThaiLX3LV6 != 0)
                {
                    decPercentLx36 = Math.Round((Decimal)(intCountTrangThaiLX3LV6 * 100 / intL6), 0, MidpointRounding.AwayFromZero);
                }
                //LV7
                decPercentLx37 = 0;
                if (intCountTrangThaiLX3LV7 != 0)
                {
                    decPercentLx37 = Math.Round((Decimal)(intCountTrangThaiLX3LV7 * 100 / intL7), 0, MidpointRounding.AwayFromZero);
                }
                //LV8
                decPercentLx38 = 0;
                if (intCountTrangThaiLX3LV8 != 0)
                {
                    decPercentLx38 = Math.Round((Decimal)(intCountTrangThaiLX3LV8 * 100 / intL8), 0, MidpointRounding.AwayFromZero);
                }
                //LV9
                decPercentLx39 = 0;
                if (intCountTrangThaiLX3LV9 != 0)
                {
                    decPercentLx39 = Math.Round((Decimal)(intCountTrangThaiLX3LV9 * 100 / intL9), 0, MidpointRounding.AwayFromZero);
                }
                strTableTemp3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLX3LV1.ToString() + "</td>";//L1
                strTableTemp3 += "\n<td class='cssPercentReport'>" + decPercentLx31.ToString() + "%</td>";
                strTableTemp3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLX3LV2.ToString() + "</td>";//L2
                strTableTemp3 += "\n<td class='cssPercentReport'>" + decPercentLx32.ToString() + "%</td>";
                strTableTemp3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLX3LV3.ToString() + "</td>";//L2
                strTableTemp3 += "\n<td class='cssPercentReport'>" + decPercentLx33.ToString() + "%</td>";
                strTableTemp3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLX3LV4.ToString() + "</td>";//L2
                strTableTemp3 += "\n<td class='cssPercentReport'>" + decPercentLx34.ToString() + "%</td>";
                strTableTemp3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLX3LV5A.ToString() + "</td>";//L2
                strTableTemp3 += "\n<td class='cssPercentReport'>" + decPercentLx35A.ToString() + "%</td>";
                strTableTemp3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLX3LV5B.ToString() + "</td>";//L2
                strTableTemp3 += "\n<td class='cssPercentReport'>" + decPercentLx35B.ToString() + "%</td>";
                strTableTemp3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLX3LV6.ToString() + "</td>";//L2
                strTableTemp3 += "\n<td class='cssPercentReport'>" + decPercentLx36.ToString() + "%</td>";
                strTableTemp3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLX3LV7.ToString() + "</td>";//L2
                strTableTemp3 += "\n<td class='cssPercentReport'>" + decPercentLx37.ToString() + "%</td>";
                strTableTemp3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLX3LV8.ToString() + "</td>";//L2
                strTableTemp3 += "\n<td class='cssPercentReport'>" + decPercentLx38.ToString() + "%</td>";
                strTableTemp3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCountTrangThaiLX3LV9.ToString() + "</td>";//L2
                strTableTemp3 += "\n<td class='cssPercentReport'>" + decPercentLx39.ToString() + "%</td>";
                strTableTemp3 += "\n</tr>";
            #endregion
            #region "View Lx2"
                //----------------------------------------------------------View Lx2-------------------------------
                strTable += "\n<tr>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Lx.2</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + (intL1 - intCountTrangThaiLV1 - intCountTrangThaiLX3LV1).ToString() + "</td>";//L1
                if ((intL1 - intCountTrangThaiLV1 - intCountTrangThaiLX3LV1) != 0)
                {
                    strTable += "\n<td class='cssPercentReport'>" + (100 - decPercentLx1L1 - decPercentLx31).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + (intL2 - intCountTrangThaiLV2 - intCountTrangThaiLX3LV2).ToString() + "</td>";//L2
                if ((intL2 - intCountTrangThaiLV2 - intCountTrangThaiLX3LV2) != 0)
                {
                    strTable += "\n<td class='cssPercentReport'>" + (100 - decPercentLx1L2 - decPercentLx32).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + (intL3 - intCountTrangThaiLV3 - intCountTrangThaiLX3LV3).ToString() + "</td>";//L3
                if ((intL3 - intCountTrangThaiLV3 - intCountTrangThaiLX3LV3) != 0)
                {
                    strTable += "\n<td class='cssPercentReport'>" + (100 - decPercentLx1L3 - decPercentLx33).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + (intL4 - intCountTrangThaiLV4 - intCountTrangThaiLX3LV4).ToString() + "</td>";//L4
                if ((intL4 - intCountTrangThaiLV4 - intCountTrangThaiLX3LV4) != 0)
                {
                    strTable += "\n<td class='cssPercentReport'>" + (100 - decPercentLx1L4 - decPercentLx34).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + (intL5A - intCountTrangThaiLV5A - intCountTrangThaiLX3LV5A).ToString() + "</td>";//L5A
                if ((intL5A - intCountTrangThaiLV5A - intCountTrangThaiLX3LV5A) != 0)
                {
                    strTable += "\n<td class='cssPercentReport'>" + (100 - decPercentLx1L5A - decPercentLx35A).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + (intL5B - intCountTrangThaiLV5B - intCountTrangThaiLX3LV5B).ToString() + "</td>";//L5B
                if ((intL5B - intCountTrangThaiLV5B - intCountTrangThaiLX3LV5B) != 0)
                {
                    strTable += "\n<td class='cssPercentReport'>" + (100 - decPercentLx1L5B - decPercentLx35B).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + (intL6 - intCountTrangThaiLV6 - intCountTrangThaiLX3LV6).ToString() + "</td>";//L6
                if ((intL6 - intCountTrangThaiLV6 - intCountTrangThaiLX3LV6) != 0)
                {
                    strTable += "\n<td class='cssPercentReport'>" + (100 - decPercentLx1L6 - decPercentLx36).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + (intL7 - intCountTrangThaiLV7 - intCountTrangThaiLX3LV7).ToString() + "</td>";//L7
                if ((intL7 - intCountTrangThaiLV7 - intCountTrangThaiLX3LV7) != 0)
                {
                    strTable += "\n<td class='cssPercentReport'>" + (100 - decPercentLx1L7 - decPercentLx37).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + (intL8 - intCountTrangThaiLV8 - intCountTrangThaiLX3LV8).ToString() + "</td>";//L8
                if ((intL8 - intCountTrangThaiLV8 - intCountTrangThaiLX3LV8) != 0)
                {
                    strTable += "\n<td class='cssPercentReport'>" + (100 - decPercentLx1L8 - decPercentLx38).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + (intL9 - intCountTrangThaiLV9 - intCountTrangThaiLX3LV9).ToString() + "</td>";//L9
                if ((intL9 - intCountTrangThaiLV9 - intCountTrangThaiLX3LV9) != 0)
                {
                    strTable += "\n<td class='cssPercentReport'>" + (100 - decPercentLx1L9 - decPercentLx39).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                strTable += "\n</tr>";
            #endregion
            strTable += strTableTemp3;
        }       
        //Tong Bang 2
        public void loadLevelViewTongBang2(ref string strTable, string strText)
        {
            strTable += "\n<tr>";
            strTable += "\n<td align='center' class='cssTableReport' rowspan='6'>&nbsp;</td>";
            strTable += "\n<tr>";
            strTable += "\n<td valign=\"middle\" class=\"cssTableReport\" rowspan='5' align='center'>Tổng</td>";
            //Tong View
            #region "View"
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap' >&nbsp;</td>";
            //Lay du lieu theo can bo
            //L1
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang2_1.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L2
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang2_2.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L3
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang2_3.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L4
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang2_4.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L5A
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang2_5A.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L5B
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang2_5B.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L6
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang2_6.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L7
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang2_7.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L8
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang2_8.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L9
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang2_9.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";


            #endregion
            strTable += "\n</tr>";
            strTable += "\n<tr>";
            #region "ViewT"
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Số lượng tổng</td>";
            //Lay du lieu theo can bo
            //L1            
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT_Bang2_1.ToString() + "</td>";
            strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>0%</td>";
            //L2           
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT_Bang2_2.ToString() + "</td>";
            if (intsumT_Bang2_2 != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT_Bang2_2 * 100 / intsumT_Bang2_1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L3
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT_Bang2_3.ToString() + "</td>";
            if (intsumT_Bang2_3 != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT_Bang2_3 * 100 / intsumT_Bang2_1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L4
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT_Bang2_4.ToString() + "</td>";
            if (intsumT_Bang2_4 != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT_Bang2_4 * 100 / intsumT_Bang2_1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L5A
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT_Bang2_5A.ToString() + "</td>";
            if (intsumT_Bang2_5A != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT_Bang2_5A * 100 / intsumT_Bang2_1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L5B
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT_Bang2_5B.ToString() + "</td>";
            if (intsumT_Bang2_5B != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT_Bang2_5B * 100 / intsumT_Bang2_1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L6
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT_Bang2_6.ToString() + "</td>";
            if (intsumT_Bang2_6 != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT_Bang2_6 * 100 / intsumT_Bang2_1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L7
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT_Bang2_7.ToString() + "</td>";
            if (intsumT_Bang2_7 != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT_Bang2_7 * 100 / intsumT_Bang2_1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L8
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT_Bang2_8.ToString() + "</td>";
            if (intsumT_Bang2_8 != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT_Bang2_8 * 100 / intsumT_Bang2_1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L9
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT_Bang2_9.ToString() + "</td>";
            if (intsumT_Bang2_9 != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT_Bang2_9 * 100 / intsumT_Bang2_1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            #endregion
            strTable += "\n</tr>";
            strTable += "\n<tr>";
            #region "ViewLx1"
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Lx.1</td>";
                //L1
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx1_Bang2_1.ToString() + "</td>";
                if (intsumLx1_Bang2_1 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_1 * 100 / intsum_Bang2_1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L2
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx1_Bang2_2.ToString() + "</td>";
                if (intsumLx1_Bang2_2 != 0)
                {

                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_2 * 100 / intsum_Bang2_2), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L3
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx1_Bang2_3.ToString() + "</td>";
                if (intsumLx1_Bang2_3 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_3 * 100 / intsum_Bang2_3), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L4
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx1_Bang2_4.ToString() + "</td>";
                if (intsumLx1_Bang2_4 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_4 * 100 / intsum_Bang2_4), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L5A
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx1_Bang2_5A.ToString() + "</td>";
                if (intsumLx1_Bang2_5A != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_5A * 100 / intsum_Bang2_5A), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L5B
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx1_Bang2_5B.ToString() + "</td>";
                if (intsumLx1_Bang2_5B != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_5B * 100 / intsum_Bang2_5B), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L6
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx1_Bang2_6.ToString() + "</td>";
                if (intsumLx1_Bang2_6 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_6 * 100 / intsum_Bang2_6), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L7
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx1_Bang2_7.ToString() + "</td>";
                if (intsumLx1_Bang2_7 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_7 * 100 / intsumT_Bang2_7), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L8
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx1_Bang2_8.ToString() + "</td>";
                if (intsumLx1_Bang2_8 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_8 * 100 / intsum_Bang2_8), 0, MidpointRounding.AwayFromZero)).ToString() + "</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L9
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx1_Bang2_9.ToString() + "</td>";
                if (intsumLx1_Bang2_9 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_9 * 100 / intsum_Bang2_9), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
            #endregion
            strTable += "\n</tr>";
            strTable += "\n<tr>";
            #region "ViewLx2"
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Lx.2</td>";
                //L1
                intsumLx2_Bang2_1 = intsum_Bang2_1 - intsumLx1_Bang2_1 - intsumLx3_Bang2_1;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx2_Bang2_1.ToString() + "</td>";
                if (intsumLx2_Bang2_1 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_1 * 100 / intsum_Bang2_1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L2
                intsumLx2_Bang2_2 = intsum_Bang2_2 - intsumLx1_Bang2_2 - intsumLx3_Bang2_2;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx2_Bang2_2.ToString() + "</td>";
                if (intsumLx2_Bang2_2 != 0)
                {

                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_2 * 100 / intsum_Bang2_2), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L3
                intsumLx2_Bang2_3 = intsum_Bang2_3 - intsumLx1_Bang2_3 - intsumLx3_Bang2_3;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx2_Bang2_3.ToString() + "</td>";
                if (intsumLx2_Bang2_3 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_3 * 100 / intsum_Bang2_3), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L4
                intsumLx2_Bang2_4 = intsum_Bang2_4 - intsumLx1_Bang2_4 - intsumLx3_Bang2_4;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx2_Bang2_4.ToString() + "</td>";
                if (intsumLx2_Bang2_4 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_4 * 100 / intsum_Bang2_4), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L5A
                intsumLx2_Bang2_5A = intsum_Bang2_5A - intsumLx1_Bang2_5A - intsumLx3_Bang2_5A;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx2_Bang2_5A.ToString() + "</td>";
                if (intsumLx2_Bang2_5A != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_5A * 100 / intsum_Bang2_5A), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L5B
                intsumLx2_Bang2_5B = intsum_Bang2_5B - intsumLx1_Bang2_5B - intsumLx3_Bang2_5B;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx2_Bang2_5B.ToString() + "</td>";
                if (intsumLx2_Bang2_5B != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_5B * 100 / intsum_Bang2_5B), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L6
                intsumLx2_Bang2_6 = intsum_Bang2_6 - intsumLx1_Bang2_6 - intsumLx3_Bang2_6;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx2_Bang2_6.ToString() + "</td>";
                if (intsumLx2_Bang2_6 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_6 * 100 / intsum_Bang2_6), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L7
                intsumLx2_Bang2_7 = intsum_Bang2_7 - intsumLx1_Bang2_7 - intsumLx3_Bang2_7;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx2_Bang2_7.ToString() + "</td>";
                if (intsumLx2_Bang2_7 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_7 * 100 / intsum_Bang2_7), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L8
                intsumLx2_Bang2_8 = intsum_Bang2_8 - intsumLx1_Bang2_8 - intsumLx3_Bang2_8;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx2_Bang2_8.ToString() + "</td>";
                if (intsumLx2_Bang2_8 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_8 * 100 / intsum_Bang2_8), 0, MidpointRounding.AwayFromZero)).ToString() + "</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L9
                intsumLx2_Bang2_9 = intsum_Bang2_9 - intsumLx1_Bang2_9 - intsumLx3_Bang2_9;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx2_Bang2_9.ToString() + "</td>";
                if (intsumLx2_Bang2_9 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_9 * 100 / intsum_Bang2_9), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
            #endregion
            strTable += "\n</tr>";
            strTable += "\n<tr>";
            #region "ViewLx3"
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Lx.3</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx3_Bang2_1.ToString() + "</td>";
                if (intsumLx3_Bang2_1 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_1 * 100 / intsum_Bang2_1), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_1 * 100 / intsum_Bang2_1), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L2
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx3_Bang2_2.ToString() + "</td>";
                if (intsumLx3_Bang2_2 != 0)
                {

                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_2 * 100 / intsum_Bang2_2), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_2 * 100 / intsum_Bang2_2), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L3
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx3_Bang2_3.ToString() + "</td>";
                if (intsumLx3_Bang2_3 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_3 * 100 / intsum_Bang2_3), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_3 * 100 / intsum_Bang2_3), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L4
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx3_Bang2_4.ToString() + "</td>";
                if (intsumLx3_Bang2_4 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_4 * 100 / intsum_Bang2_4), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_4 * 100 / intsum_Bang2_4), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L5A
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx3_Bang2_5A.ToString() + "</td>";
                if (intsumLx3_Bang2_5A != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_5A * 100 / intsum_Bang2_5A), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_5A * 100 / intsum_Bang2_5A), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L5B
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx3_Bang2_5B.ToString() + "</td>";
                if (intsumLx3_Bang2_5B != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_5B * 100 / intsum_Bang2_5B), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_5B * 100 / intsum_Bang2_5B), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L6
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx3_Bang2_6.ToString() + "</td>";
                if (intsumLx3_Bang2_6 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_6 * 100 / intsum_Bang2_6), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_6 * 100 / intsum_Bang2_6), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L7
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx3_Bang2_7.ToString() + "</td>";
                if (intsumLx3_Bang2_7 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_7 * 100 / intsum_Bang2_7), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_7 * 100 / intsum_Bang2_7), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L8
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx3_Bang2_8.ToString() + "</td>";
                if (intsumLx3_Bang2_8 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_8 * 100 / intsum_Bang2_8), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_8 * 100 / intsum_Bang2_8), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L9
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx3_Bang2_9.ToString() + "</td>";
                if (intsumLx3_Bang2_9 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx2_Bang2_9 * 100 / intsum_Bang2_9), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx1_Bang2_9 * 100 / intsum_Bang2_9), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }


            #endregion
            strTable += "\n</tr>";

            strTable += "\n</tr>";
        }
        //load Quyen
        public void loadQuyenNhom(ref string strTable, int intQuyenID,int NguonID,int TruongID)
        {
            DataSet dsNguoiDung = objNguoidung.loadQuyenNguoiDungByQuyen(intQuyenID, 1);
            if (dsNguoiDung != null && dsNguoiDung.Tables[0].Rows.Count > 0 )
            {
                DataRow[] drNguoiDungV = dsNguoiDung.Tables[0].Select("ID <> 1");
                foreach (DataRow dr in drNguoiDungV)
                {
                    strTable += "\n<tr>";
                    strTable += "\n<td class='cssTableReport'";
                    int intNguoiDung = Convert.ToInt32(dr["ID"].ToString());
                    DataSet dsNguoiDungCapDuoi = objNguoidung.loadQuyenNguoiDungCapDuoiByNguoiDung(intNguoiDung);
                    if (dsNguoiDungCapDuoi != null && dsNguoiDungCapDuoi.Tables[0].Rows.Count > 0)
                    {
                        strTable += " rowspan='" + (dsNguoiDungCapDuoi.Tables[0].Rows.Count * 6).ToString() + "' >" + dr["HoTen"].ToString() + "</td>";
                        int i = 0;
                        foreach (DataRow drNguoiDungCapDuoi in dsNguoiDungCapDuoi.Tables[0].Rows)
                        {
                            if (i != 0)
                            {
                                strTable += "\n<tr>";
                            }
                            i++;
                            strTable += "\n<td class='cssTableReport' rowspan='5'>" + drNguoiDungCapDuoi["HoTen"].ToString() + "</td>";
                            loadLevelView(ref strTable, "&nbsp;", Convert.ToInt32(drNguoiDungCapDuoi["ID"].ToString()),NguonID,TruongID);

                            strTable += "\n<tr>";
                            strTable += "\n<td style='height:20px;background-color:#C0C0C0;' colspan='22'></td>";
                            strTable += "\n</tr>";
                        }
                    }
                    else
                    {
                        strTable += ">" + dr["HoTen"].ToString() + "</td>";
                        strTable += "\n<td class='cssReport23Title1'>TVTS</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L1</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";

                        strTable += "\n<td class='cssReport23Title1'>L2</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L3</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L4</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L5A</td>";

                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L5B</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L6</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L7</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";

                        strTable += "\n<td class='cssReport23Title1'>L8</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L9</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n</tr>";
                    }
                }
                loadLevelViewTongBang2(ref strTable, "&nbsp;Tong");
            }
        }
        #endregion
        //load tu bang ReportS23Truong
        #region "Bang 1"

        public int loadTotalFinishS23Truong(DataRow drTemp, ref string strTable,int NguonID,int TruongID)
        {
            int intTotalFinish = Convert.ToInt32(drTemp["Lx1"].ToString()) + Convert.ToInt32(drTemp["Lx2"].ToString()) + Convert.ToInt32(drTemp["Lx3"].ToString());
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalFinish.ToString() + "</td>";//L2
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            return intTotalFinish;
        }
        public int loadTotalFinishTS23Truong(DataRow drTemp, ref string strTable, int NguonID,int TruongID)
        {
            int intTotalFinish = Convert.ToInt32(drTemp["SLT"].ToString());
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalFinish.ToString() + "</td>";//L1
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            return intTotalFinish;
        }
        public int loadTotalFinishTS23Truong(DataRow drTemp, ref string strTable, int intT, int NguonID, int TruongID)
        {
            int intTotalFinish = Convert.ToInt32(drTemp["SLT"].ToString());
            if (intT != 0)
            {
                int intPecentSLTLv2 = Convert.ToInt32(intTotalFinish * 100 / intT);
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalFinish.ToString() + "</td>";//L2
                strTable += "\n<td class='cssPercentReport'>" + intPecentSLTLv2.ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intTotalFinish.ToString() + "</td>";//L1
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            return intTotalFinish;
        }
        public decimal loadTotalFinishLx1(DataRow drTemp, ref string strTable, int intT, ref int intLx1L1, int NguonID,int TruongID)
        {
            decimal decPercentReport = 0;
            intLx1L1 = Convert.ToInt32(drTemp["Lx1"].ToString());
            if (intLx1L1 != 0)
            {
                decPercentReport = (Decimal)(intLx1L1 * 100 / intT);
                decPercentReport = Math.Round(decPercentReport, 0, MidpointRounding.AwayFromZero);
            }
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx1L1.ToString() + "</td>";
            strTable += "\n<td class='cssPercentReport'>" + decPercentReport.ToString() + "%</td>";
            return decPercentReport;
        }
        public decimal loadTotalFinishLx3(DataRow drTemp, ref string strTable, int intT, ref int intLx1L3, int NguonID, int TruongID)
        {
            decimal decPercentReport = 0;
            intLx1L3 = Convert.ToInt32(drTemp["Lx3"].ToString());
            if (intLx1L3 != 0)
            {
                decPercentReport = (Decimal)(intLx1L3 * 100 / intT);
                decPercentReport = Math.Round(decPercentReport, 0, MidpointRounding.AwayFromZero);
            }
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx1L3.ToString() + "</td>";
            strTable += "\n<td class='cssPercentReport'>" + decPercentReport.ToString() + "%</td>";
            return decPercentReport;
        }
        public decimal loadTotalFinishLx2(DataRow drTemp, ref string strTable, int intT, ref int intLx1L2, int NguonID, int TruongID)
        {
            decimal decPercentReport = 0;
            int intLx1L1 = Convert.ToInt32(drTemp["Lx1"].ToString());
            intLx1L2 = Convert.ToInt32(drTemp["Lx2"].ToString());
            int intLx1L3 = Convert.ToInt32(drTemp["Lx3"].ToString());
            if (intLx1L2 != 0)
            {
                decPercentReport = 100 - (Math.Round((Decimal)(intLx1L1 * 100 / intT), 0, MidpointRounding.AwayFromZero) + Math.Round((Decimal)(intLx1L3 * 100 / intT), 0, MidpointRounding.AwayFromZero));
            }
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx1L2.ToString() + "</td>";
            strTable += "\n<td class='cssPercentReport'>" + decPercentReport.ToString() + "%</td>";
            return decPercentReport;
            
        }
        public void loadLevelViewReportS23Truong(ref string strTable, string strText, int intNguoiDungID, int NguonID, int TruongID)
        {
            int intTotalFinishL1 = 0;
            int intTotalFinishL2 = 0;
            int intTotalFinishL3 = 0;
            int intTotalFinishL4 = 0;
            int intTotalFinishL5A = 0;
            int intTotalFinishL5B = 0;
            int intTotalFinishL6 = 0;
            int intTotalFinishL7 = 0;
            int intTotalFinishL8 = 0;
            int intTotalFinishL9 = 0;
            #region "View tong tren cung"
                //Lay du lieu theo can bo
                DataTable dtDataByStaff = m_dtDataReport1.Clone();
                DataRow[] drDataTemp;
                if (m_dtDataReport1.Rows.Count > 0)
                {
                    drDataTemp = m_dtDataReport1.Select("NguoiDungID=" + intNguoiDungID.ToString());
                    foreach (DataRow dr in drDataTemp)
                    {
                        dtDataByStaff.ImportRow(dr);
                    }
                }

                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + strText + "</td>";
                //LV1
                DataTable dtReportTemp = dtDataByStaff.Clone();
                DataRow[] drReceiverTemp;
                drReceiverTemp = dtDataByStaff.Select("LevelID=1");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intTotalFinishL1 = loadTotalFinishS23Truong(drReceiverTemp[0], ref strTable,NguonID,TruongID);
                    intsum1 += intTotalFinishL1;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                }
               //LV2
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=2");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intTotalFinishL2 = loadTotalFinishS23Truong(drReceiverTemp[0], ref strTable, NguonID, TruongID);
                    intsum2+= intTotalFinishL2;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                }
                //LV3
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=3");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intTotalFinishL3 = loadTotalFinishS23Truong(drReceiverTemp[0], ref strTable, NguonID, TruongID);
                    intsum3 += intTotalFinishL3;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                }
                //LV4
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=4");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intTotalFinishL4 = loadTotalFinishS23Truong(drReceiverTemp[0], ref strTable, NguonID, TruongID);
                    intsum4 += intTotalFinishL4;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                }
                ////LV5A
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=5");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intTotalFinishL5A = loadTotalFinishS23Truong(drReceiverTemp[0], ref strTable, NguonID, TruongID);
                    intsum5A += intTotalFinishL5A;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                }
                ////LV5B
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=6");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intTotalFinishL5B = loadTotalFinishS23Truong(drReceiverTemp[0], ref strTable, NguonID, TruongID);
                    intsum5B += intTotalFinishL5B;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                }
                //LV6
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=7");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intTotalFinishL6 = loadTotalFinishS23Truong(drReceiverTemp[0], ref strTable, NguonID, TruongID);
                    intsum6 += intTotalFinishL6;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                }
                //LV7
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=8");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intTotalFinishL7 = loadTotalFinishS23Truong(drReceiverTemp[0], ref strTable, NguonID, TruongID);
                    intsum7 += intTotalFinishL7;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                }
                //LV8
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=9");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intTotalFinishL8 = loadTotalFinishS23Truong(drReceiverTemp[0], ref strTable, NguonID, TruongID);
                    intsum8 += intTotalFinishL8;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                }
                //LV9
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=10");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intTotalFinishL9 = loadTotalFinishS23Truong(drReceiverTemp[0], ref strTable, NguonID, TruongID);
                    intsum9 += intTotalFinishL9;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
                }

                strTable += "\n</tr>";
            #endregion
            #region "So luong tong"
                strTable += "\n<tr>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Số lượng tổng</td>";
                //Tong LV1
                dtReportTemp.Clear();
                int intTotalFinishTL1 = 0;
                drReceiverTemp = dtDataByStaff.Select("LevelID=1");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intTotalFinishTL1 = loadTotalFinishTS23Truong(drReceiverTemp[0], ref strTable, NguonID, TruongID);
                    intsumT1 += intTotalFinishTL1;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";//L1
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0%</td>";
                }
                //Tong LV2
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=2");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intsumT2 += loadTotalFinishTS23Truong(drReceiverTemp[0], ref strTable, intTotalFinishTL1, NguonID, TruongID);                    
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";//L1
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0%</td>";
                }
                //Tong LV3
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=3");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intsumT3 += loadTotalFinishTS23Truong(drReceiverTemp[0], ref strTable, intTotalFinishTL1, NguonID, TruongID);
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";//L1
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0%</td>";
                }

                //Tong LV4
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=4");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intsumT4 += loadTotalFinishTS23Truong(drReceiverTemp[0], ref strTable, intTotalFinishTL1, NguonID, TruongID);
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";//L1
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0%</td>";
                }
                //Tong LV5A
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=5");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intsumT5A += loadTotalFinishTS23Truong(drReceiverTemp[0], ref strTable, intTotalFinishTL1, NguonID, TruongID);
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";//L1
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0%</td>";
                }

                //Tong LV5B
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=6");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intsumT5B += loadTotalFinishTS23Truong(drReceiverTemp[0], ref strTable, intTotalFinishTL1, NguonID, TruongID);
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";//L1
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0%</td>";
                }
                //Tong LV6
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=7");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intsumT6 += loadTotalFinishTS23Truong(drReceiverTemp[0], ref strTable, intTotalFinishTL1, NguonID, TruongID);
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";//L1
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0%</td>";
                }

                //Tong LV7
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=8");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intsumT7 += loadTotalFinishTS23Truong(drReceiverTemp[0], ref strTable, intTotalFinishTL1, NguonID, TruongID);
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";//L1
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0%</td>";
                }

                //Tong LV8
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=9");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intsumT8 += loadTotalFinishTS23Truong(drReceiverTemp[0], ref strTable, intTotalFinishTL1, NguonID, TruongID);
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";//L1
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0%</td>";
                }

                //Tong LV9
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=10");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    intsumT9 += loadTotalFinishTS23Truong(drReceiverTemp[0], ref strTable, intTotalFinishTL1, NguonID, TruongID);
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";//L1
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0%</td>";
                }
                strTable += "\n</tr>";
            #endregion
            #region "Lx1"
                //LV1
                int intLx1L1 = 0;
                strTable += "\n<tr>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Lx.1</td>";
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=1");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx1L1 = loadTotalFinishLx1(drReceiverTemp[0], ref strTable, intTotalFinishL1, ref intLx1L1, NguonID, TruongID);
                    intsumLx11 += intLx1L1;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx1L1.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV2
                int intLx1L2 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=2");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx1L1 = loadTotalFinishLx1(drReceiverTemp[0], ref strTable, intTotalFinishL2, ref intLx1L2, NguonID, TruongID);
                    intsumLx12 += intLx1L2;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx1L2.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV3
                int intLx1L3 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=3");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx1L1 = loadTotalFinishLx1(drReceiverTemp[0], ref strTable, intTotalFinishL3, ref intLx1L3, NguonID, TruongID);
                    intsumLx13 += intLx1L3;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx1L3.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV4
                int intLx1L4 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=4");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx1L1 = loadTotalFinishLx1(drReceiverTemp[0], ref strTable, intTotalFinishL4, ref intLx1L4, NguonID, TruongID);
                    intsumLx14 += intLx1L4;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx1L4.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV5A
                int intLx1L5A = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=5");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx1L1 = loadTotalFinishLx1(drReceiverTemp[0], ref strTable, intTotalFinishL5A, ref intLx1L5A, NguonID, TruongID);
                    intsumLx15A += intLx1L5A;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx1L5A.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV3
                int intLx1L5B = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=6");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx1L1 = loadTotalFinishLx1(drReceiverTemp[0], ref strTable, intTotalFinishL5B, ref intLx1L5B, NguonID, TruongID);
                    intsumLx15B += intLx1L5B;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx1L3.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV7
                int intLx1L6 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=7");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx1L1 = loadTotalFinishLx1(drReceiverTemp[0], ref strTable, intTotalFinishL6, ref intLx1L6, NguonID, TruongID);
                    intsumLx16 += intLx1L6;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx1L6.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV6
                int intLx1L7 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=8");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx1L1 = loadTotalFinishLx1(drReceiverTemp[0], ref strTable, intTotalFinishL7, ref intLx1L7, NguonID, TruongID);
                    intsumLx17 += intLx1L7;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx1L7.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV8
                int intLx1L8 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=9");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx1L1 = loadTotalFinishLx1(drReceiverTemp[0], ref strTable, intTotalFinishL8, ref intLx1L8, NguonID, TruongID);
                    intsumLx18 += intLx1L8;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx1L8.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }

                //LV9
                int intLx1L9 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=10");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx1L1 = loadTotalFinishLx1(drReceiverTemp[0], ref strTable, intTotalFinishL9, ref intLx1L9, NguonID, TruongID);
                    intsumLx19 += intLx1L9;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx1L9.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                strTable += "\n</tr>";
            #endregion
            #region "Lx3"
                //LV1
                int intLx3L1 = 0;
                string strTableLx3 = "\n<tr>\n<td class='cssTitleReport' nowrap='nowrap'>Lx.3</td>";
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=1");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx3L1 = loadTotalFinishLx3(drReceiverTemp[0], ref strTableLx3, intTotalFinishL1, ref intLx3L1, NguonID, TruongID);
                    intsumLx31 += intLx3L1;
                }
                else
                {
                    strTableLx3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx3L1.ToString() + "</td>";
                    strTableLx3 += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV2
                int intLx3L2 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=2");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx3L1 = loadTotalFinishLx3(drReceiverTemp[0], ref strTableLx3, intTotalFinishL2, ref intLx3L2, NguonID, TruongID);
                    intsumLx32 += intLx3L2;
                }
                else
                {
                    strTableLx3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx3L2.ToString() + "</td>";
                    strTableLx3 += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV3
                int intLx3L3 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=3");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx3L1 = loadTotalFinishLx3(drReceiverTemp[0], ref strTableLx3, intTotalFinishL3, ref intLx3L3, NguonID, TruongID);
                    intsumLx33 += intLx3L3;
                }
                else
                {
                    strTableLx3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx3L3.ToString() + "</td>";
                    strTableLx3 += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV4
                int intLx3L4 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=4");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx3L1 = loadTotalFinishLx3(drReceiverTemp[0], ref strTableLx3, intTotalFinishL4, ref intLx3L4, NguonID, TruongID);
                    intsumLx34 += intLx3L4;
                }
                else
                {
                    strTableLx3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx3L4.ToString() + "</td>";
                    strTableLx3 += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV5A
                int intLx3L5A = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=5");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx3L1 = loadTotalFinishLx3(drReceiverTemp[0], ref strTableLx3, intTotalFinishL5A, ref intLx3L5A, NguonID, TruongID);
                    intsumLx35A += intLx3L5A;
                }
                else
                {
                    strTableLx3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx3L5A.ToString() + "</td>";
                    strTableLx3 += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV3
                int intLx3L5B = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=6");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx3L1 = loadTotalFinishLx3(drReceiverTemp[0], ref strTableLx3, intTotalFinishL5B, ref intLx3L5B, NguonID, TruongID);
                    intsumLx35B += intLx3L5B;
                }
                else
                {
                    strTableLx3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx3L3.ToString() + "</td>";
                    strTableLx3 += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV7
                int intLx3L6 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=7");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx3L1 = loadTotalFinishLx3(drReceiverTemp[0], ref strTableLx3, intTotalFinishL6, ref intLx3L6, NguonID, TruongID);
                    intsumLx36 += intLx3L6;
                }
                else
                {
                    strTableLx3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx3L6.ToString() + "</td>";
                    strTableLx3 += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV6
                int intLx3L7 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=8");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx3L1 = loadTotalFinishLx3(drReceiverTemp[0], ref strTableLx3, intTotalFinishL7, ref intLx3L7, NguonID, TruongID);
                    intsumLx37 += intLx3L7;
                }
                else
                {
                    strTableLx3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx3L7.ToString() + "</td>";
                    strTableLx3 += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV8
                int intLx3L8 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=9");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx3L1 = loadTotalFinishLx3(drReceiverTemp[0], ref strTableLx3, intTotalFinishL8, ref intLx3L8, NguonID, TruongID);
                    intsumLx38 += intLx3L8;
                }
                else
                {
                    strTableLx3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx3L8.ToString() + "</td>";
                    strTableLx3 += "\n<td class='cssPercentReport'>0%</td>";
                }

                //LV9
                int intLx3L9 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=10");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx3L1 = loadTotalFinishLx3(drReceiverTemp[0], ref strTableLx3, intTotalFinishL9, ref intLx3L9, NguonID, TruongID);
                    intsumLx39 += intLx3L9;
                }
                else
                {
                    strTableLx3 += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx3L9.ToString() + "</td>";
                    strTableLx3 += "\n<td class='cssPercentReport'>0%</td>";
                }
                strTableLx3 += "\n</tr>";
                #endregion
            #region "Lx2"
                //LV1
                int intLx2L1 = 0;
                strTable += "\n<tr>\n<td class='cssTitleReport' nowrap='nowrap'>Lx.2</td>";
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=1");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx2L1 = loadTotalFinishLx2(drReceiverTemp[0], ref strTable, intTotalFinishL1, ref intLx2L1, NguonID, TruongID);
                    intsumLx21 += intLx2L1;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx2L1.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV2
                int intLx2L2 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=2");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx2L1 = loadTotalFinishLx2(drReceiverTemp[0], ref strTable, intTotalFinishL2, ref intLx2L2, NguonID, TruongID);
                    intsumLx22 += intLx2L2;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx2L2.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV3
                int intLx2L3 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=3");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx2L1 = loadTotalFinishLx2(drReceiverTemp[0], ref strTable, intTotalFinishL3, ref intLx2L3, NguonID, TruongID);
                    intsumLx23 += intLx2L3;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx2L3.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV4
                int intLx2L4 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=4");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx2L1 = loadTotalFinishLx2(drReceiverTemp[0], ref strTable, intTotalFinishL4, ref intLx2L4, NguonID, TruongID);
                    intsumLx24 += intLx2L4;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx2L4.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV5A
                int intLx2L5A = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=5");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx2L1 = loadTotalFinishLx2(drReceiverTemp[0], ref strTable, intTotalFinishL5A, ref intLx2L5A, NguonID, TruongID);
                    intsumLx25A += intLx2L5A;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx2L5A.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV3
                int intLx2L5B = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=6");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx2L1 = loadTotalFinishLx2(drReceiverTemp[0], ref strTable, intTotalFinishL5B, ref intLx2L5B, NguonID, TruongID);
                    intsumLx25B += intLx2L5B;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx2L3.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV7
                int intLx2L6 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=7");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx2L1 = loadTotalFinishLx2(drReceiverTemp[0], ref strTable, intTotalFinishL6, ref intLx2L6, NguonID, TruongID);
                    intsumLx26 += intLx2L6;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx2L6.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV6
                int intLx2L7 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=8");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx2L1 = loadTotalFinishLx2(drReceiverTemp[0], ref strTable, intTotalFinishL7, ref intLx2L7, NguonID, TruongID);
                    intsumLx27 += intLx2L7;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx2L7.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //LV8
                int intLx2L8 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=9");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx2L1 = loadTotalFinishLx2(drReceiverTemp[0], ref strTable, intTotalFinishL8, ref intLx2L8, NguonID, TruongID);
                    intsumLx28 += intLx2L8;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx2L8.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }

                //LV9
                int intLx2L9 = 0;
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=10");
                if (drReceiverTemp != null && drReceiverTemp.Length > 0)
                {
                    decPercentReportLx2L1 = loadTotalFinishLx2(drReceiverTemp[0], ref strTable, intTotalFinishL9, ref intLx2L9, NguonID, TruongID);
                    intsumLx29 += intLx2L9;
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intLx2L9.ToString() + "</td>";
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                strTable += "\n</tr>";

            #endregion

            strTable += strTableLx3;
        }               
        
        //Tong Bang 1
        public void loadLevelViewTongBang1(ref string strTable, string strText,int NguonID, int TruongID)
        {
            strTable += "\n<tr>";
            strTable += "\n<td align='center' class='cssTableReport' rowspan='6'>&nbsp;</td>";
            strTable += "\n<tr>";
            strTable += "\n<td valign=\"middle\" class=\"cssTableReport\" rowspan='5' align='center'>Tổng</td>";
            //Tong View
            #region "View"
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap' >&nbsp;</td>";
            //Lay du lieu theo can bo
            //L1
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum1.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L2
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum2.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L3
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum3.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L4
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum4.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L5A
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum5A.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L5B
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum5B.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L6
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum6.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L7
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum7.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L8
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum8.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";
            //L9
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum9.ToString() + "</td>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>&nbsp;</td>";


            #endregion
            strTable += "\n</tr>";
            strTable += "\n<tr>";
            #region "ViewT"
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Số lượng tổng</td>";
                //Lay du lieu theo can bo
                //L1
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT1.ToString() + "</td>";
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>0%</td>";
                //L2
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT2.ToString() + "</td>";
                if (intsumT2 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT2 * 100 / intsumT1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L3
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT3.ToString() + "</td>";
                if (intsumT3 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT3 * 100 / intsumT1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L4
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT4.ToString() + "</td>";
                if (intsumT4 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT4 * 100 / intsumT1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L5A
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT5A.ToString() + "</td>";
                if (intsumT5A != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT5A * 100 / intsumT1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L5B
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT5B.ToString() + "</td>";
                if (intsumT5B != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT5B * 100 / intsumT1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L6
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT6.ToString() + "</td>";
                if (intsumT6 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT6 * 100 / intsumT1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L7
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT7.ToString() + "</td>";
                if (intsumT7 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT7 * 100 / intsumT1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L8
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT8.ToString() + "</td>";
                if (intsumT8 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT8 * 100 / intsumT1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L9
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT9.ToString() + "</td>";
                if (intsumT9 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumT9 * 100 / intsumT1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }


                #endregion
            strTable += "\n</tr>";
            strTable += "\n<tr>";
             #region "ViewLx1"
               strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Lx.1</td>";
                //L1
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx11.ToString() + "</td>";
                if (intsumLx11 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx11 * 100 / intsum1), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L2
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx12.ToString() + "</td>";
                if (intsumLx12 != 0)
                {

                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx12 * 100 / intsum2), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L3
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx13.ToString() + "</td>";
                if (intsumLx13 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx13 * 100 / intsum3), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                 }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L4
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx14.ToString() + "</td>";
                if (intsumLx14 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx14 * 100 / intsum4), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L5A
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx15A.ToString() + "</td>";
                if (intsumLx15A != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx15A * 100 / intsum5A), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";                    
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L5B
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx15B.ToString() + "</td>";
                if (intsumLx15B != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx15B * 100 / intsum5B), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L6
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx16.ToString() + "</td>";
                if (intsumLx16 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx16 * 100 / intsum6), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L7
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx17.ToString() + "</td>";
                if (intsumLx17 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx17 * 100 / intsum7), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L8
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx18.ToString() + "</td>";
                if (intsumLx18 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx18 * 100 / intsum8), 0, MidpointRounding.AwayFromZero)).ToString() + "</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L9
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx19.ToString() + "</td>";
                if (intsumLx19 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx19 * 100 / intsum9), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }

                #endregion
            strTable += "\n</tr>";
            #region "ViewLx2"
            strTable += "\n<tr>\n<td class='cssTitleReport' nowrap='nowrap'>Lx.2</td>";
            //L1
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx21.ToString() + "</td>";
            if (intsumLx21 != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" +
                    (Math.Round(Convert.ToDecimal(intsumLx21 * 100 / intsum1), 0, MidpointRounding.AwayFromZero)) + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L2
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx22.ToString() + "</td>";
            if (intsumLx22 != 0)
            {

                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx22 * 100 / intsum2), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L3
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx23.ToString() + "</td>";
            if (intsumLx23 != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx23 * 100 / intsum3), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L4
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx24.ToString() + "</td>";
            if (intsumLx24 != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx24 * 100 / intsumT4), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L5A
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx25A.ToString() + "</td>";
            if (intsumLx25A != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx25A * 100 / intsum5A), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L5B
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx25B.ToString() + "</td>";
            if (intsumLx25B != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx25B * 100 / intsum5B), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L6
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx26.ToString() + "</td>";
            if (intsumLx26 != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx26 * 100 / intsum6), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L7
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx27.ToString() + "</td>";
            if (intsumLx27 != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx27 * 100 / intsum7), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L8
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx28.ToString() + "</td>";
            if (intsumLx28 != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx28 * 100 / intsum8), 0, MidpointRounding.AwayFromZero)).ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            //L9
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx29.ToString() + "</td>";
            if (intsumLx29 != 0)
            {
                strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (Math.Round(Convert.ToDecimal(intsumLx29 * 100 / intsum9), 0, MidpointRounding.AwayFromZero)).ToString() + "%</td>";
            }
            else
            {
                strTable += "\n<td class='cssPercentReport'>0%</td>";
            }
            strTable += "\n</tr>";
            #endregion
            strTable += "\n<tr>";

            #region "ViewLx3"
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Lx.3</td>";
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx21.ToString() + "</td>";
                if (intsumLx31 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx21 * 100 / intsum1), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx11 * 100 / intsum1), 0, MidpointRounding.AwayFromZero)) 
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L2
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx22.ToString() + "</td>";
                if (intsumLx32 != 0)
                {

                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx22 * 100 / intsum2), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx12 * 100 / intsum2), 0, MidpointRounding.AwayFromZero)) 
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L3
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx23.ToString() + "</td>";
                if (intsumLx33 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx23 * 100 / intsum3), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx13 * 100 / intsum3), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L4
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx24.ToString() + "</td>";
                if (intsumLx34 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx24 * 100 / intsum4), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx14 * 100 / intsum4), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L5A
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx25A.ToString() + "</td>";
                if (intsumLx35A != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx25A * 100 / intsum5A), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx15A * 100 / intsum5A), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L5B
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx25B.ToString() + "</td>";
                if (intsumLx35B != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx25B * 100 / intsum5B), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx15B * 100 / intsum5B), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L6
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx26.ToString() + "</td>";
                if (intsumLx36 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx26 * 100 / intsum6), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx16 * 100 / intsum6), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L7
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx27.ToString() + "</td>";
                if (intsumLx37 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx27 * 100 / intsumT7), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx17 * 100 / intsumT7), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L8
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx28.ToString() + "</td>";
                if (intsumLx38 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx28 * 100 / intsum8), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx18 * 100 / intsum8), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
                //L9
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumLx29.ToString() + "</td>";
                if (intsumLx39 != 0)
                {
                    strTable += "\n<td class='cssPercentReport' nowrap='nowrap'>" + (100 -
                        (Math.Round(Convert.ToDecimal(intsumLx29 * 100 / intsum9), 0, MidpointRounding.AwayFromZero)) -
                        (Math.Round(Convert.ToDecimal(intsumLx19 * 100 / intsum9), 0, MidpointRounding.AwayFromZero))
                        ).ToString() + "%</td>";
                }
                else
                {
                    strTable += "\n<td class='cssPercentReport'>0%</td>";
                }
            #endregion
            strTable += "\n</tr>";
            strTable += "\n</tr>";
        }
        //load Quyen
        public void loadQuyenNhomReportS23Truong(ref string strTable, int intQuyenID, int NguonID,int TruongID)
        {
            DataSet dsNguoiDung = objNguoidung.loadQuyenNguoiDungByQuyen(intQuyenID, 1);
            if (dsNguoiDung != null)
            {
                DataRow[] drNguoiDungV = dsNguoiDung.Tables[0].Select("ID <> 1");
                foreach (DataRow dr in drNguoiDungV)
                {
                    strTable += "\n<tr >";
                    strTable += "\n<td align='center' class='cssTableReport'  ";
                    int intNguoiDung = Convert.ToInt32(dr["ID"].ToString());
                    DataSet dsNguoiDungCapDuoi = objNguoidung.loadQuyenNguoiDungCapDuoiByNguoiDung(intNguoiDung);
                    DataSet dsReportHocVien = objReport.loadReportHocVien23STruong(intNguoiDung, NguonID,TruongID);
                    if (dsNguoiDungCapDuoi != null && dsNguoiDungCapDuoi.Tables[0].Rows.Count > 0)
                    {
                        strTable += " rowspan='" + (dsNguoiDungCapDuoi.Tables[0].Rows.Count * 6).ToString() + "' >" + dr["HoTen"].ToString() + "</td>";
                        int i = 0;
                        foreach (DataRow drNguoiDungCapDuoi in dsNguoiDungCapDuoi.Tables[0].Rows)
                        {
                            if (i != 0)
                            {
                                strTable += "\n<tr>";
                            }
                            i++;
                            strTable += "\n<td valign=\"middle\" class=\"cssTableReport\" rowspan='5' align='center'>" + drNguoiDungCapDuoi["HoTen"].ToString() + "</td>";

                            loadLevelViewReportS23Truong(ref strTable, "&nbsp;", Convert.ToInt32(drNguoiDungCapDuoi["ID"].ToString()), NguonID,TruongID);                           
                           
                            strTable += "\n<tr>";
                            strTable += "\n<td style='height:20px;background-color:#C0C0C0;' colspan='22'></td>";
                            strTable += "\n</tr>";
                        }
                        
                    }
                    else
                    {
                        strTable += ">" + dr["HoTen"].ToString() + "</td>";
                        strTable += "\n<td class='cssReport23Title1'>TVTS</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L1</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";

                        strTable += "\n<td class='cssReport23Title1'>L2</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L3</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L4</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L5A</td>";

                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L5B</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L6</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L7</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";

                        strTable += "\n<td class='cssReport23Title1'>L8</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L9</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n</tr>";
                    }
                }
                
                loadLevelViewTongBang1(ref strTable, "&nbsp;Tong",NguonID,TruongID);
              
            }
        }
        #endregion
        //Tong bang 3
        #region "Bang 3"
        //bang ReportS23Truong
        public void loadReportbyTbReportS23Truong(ref string strTable, int NguonID,int TruongID)
        {
            strTable += "<table cellpadding='2' cellspacing='0' class='cssTableReport'>";
            strTable += "\n<tr>";
            strTable += "\n<td class='cssReport23Title1'>Nhóm</td>";
            strTable += "\n<td class='cssReport23Title1'>TVTS</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            strTable += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L1</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";

            strTable += "\n<td class='cssReport23Title1'>L2</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L3</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L4</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L5A</td>";

            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L5B</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L6</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L7</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";

            strTable += "\n<td class='cssReport23Title1'>L8</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L9</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n</tr>";
            loadQuyenNhomReportS23Truong(ref strTable, 4, NguonID,TruongID);
            strTable += "\n</table>";
        }
        //bang Hocvien
        public void loadReportbyTbHocVien(ref string strTable, int NguonID,int TruongID)
        {
            strTable += "<table cellpadding='2' cellspacing='0' class='cssTableReport' >";
            strTable += "\n<tr>";
            strTable += "\n<td class='cssReport23Title1' >Nhóm</td>";
            strTable += "\n<td class='cssReport23Title1'>TVTS</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            strTable += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L1</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";

            strTable += "\n<td class='cssReport23Title1'>L2</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L3</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L4</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L5A</td>";

            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L5B</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L6</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L7</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";

            strTable += "\n<td class='cssReport23Title1'>L8</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n<td class='cssReport23Title1'>L9</td>";
            strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
            strTable += "\n</tr>";
            loadQuyenNhom(ref strTable, 4, NguonID,TruongID);
            strTable += "\n</table>";
        }
        //Tong so tu 2 bang Report va hocvien
        public void loadQuyenNhomReportTotal(ref string strTable, int intQuyenID, int NguonID,int TruongID)
        {
            DataSet dsNguoiDung = objNguoidung.loadQuyenNguoiDungByQuyen(intQuyenID, 1);
            if (dsNguoiDung != null)
            {
                DataRow[] drNguoiDungV = dsNguoiDung.Tables[0].Select("ID <> 1");
                foreach (DataRow dr in drNguoiDungV)
                {
                    strTable += "\n<tr>";
                    int intNguoiDung = Convert.ToInt32(dr["ID"].ToString());
                    DataSet dsNguoiDungCapDuoi = objNguoidung.loadQuyenNguoiDungCapDuoiByNguoiDung(intNguoiDung);
                    if (dsNguoiDungCapDuoi != null && dsNguoiDungCapDuoi.Tables[0].Rows.Count > 0)
                    {
                       // strTable += " rowspan='" + (dsNguoiDungCapDuoi.Tables[0].Rows.Count * 3).ToString() + "' >" + dr["HoTen"].ToString() + "</td>";
                        int i = 0;
                        foreach (DataRow drNguoiDungCapDuoi in dsNguoiDungCapDuoi.Tables[0].Rows)
                        {
                            if (i != 0)
                            {
                                strTable += "\n<tr>";
                            }
                            i++;
                            strTable += "\n<td class='cssTableReport' rowspan='5'>" + drNguoiDungCapDuoi["HoTen"].ToString() + "</td>";
                           
                           // strTable += "\n</tr>";
                            loadLevelTotal(ref strTable, Convert.ToInt32(drNguoiDungCapDuoi["ID"].ToString()), NguonID,TruongID);
                            strTable += "\n<tr>";
                            strTable += "\n<td style='height:20px;background-color:#C0C0C0;' colspan='13'></td>";
                            strTable += "\n</tr>";
                        }
                    }
                    else
                    {
                        strTable += "\n<td class='cssReport23Title1'";
                        strTable += ">TVTS</td>";
                        strTable += "\n<td class='cssReport23Title1'>&nbsp;</td>";
                        strTable += "\n<td class='cssReport23Title1'>L1</td>";

                        strTable += "\n<td class='cssReport23Title1'>L2</td>";
                        strTable += "\n<td class='cssReport23Title1'>L3</td>";
                        strTable += "\n<td class='cssReport23Title1'>L4</td>";
                        strTable += "\n<td class='cssReport23Title1'>L5A</td>";

                        strTable += "\n<td class='cssReport23Title1'>L5B</td>";
                        strTable += "\n<td class='cssReport23Title1'>L6</td>";
                        strTable += "\n<td class='cssReport23Title1'>L7</td>";

                        strTable += "\n<td class='cssReport23Title1'>L8</td>";
                        strTable += "\n<td class='cssReport23Title1'>L9</td>";
                        strTable += "\n<td class='cssReport23Title1'>T</td>";
                        strTable += "\n</tr>";
                    }
                }
                loadLevelViewTongBang3(ref strTable, "Tong", NguonID,TruongID);
            }
        }
        //Tong Bang 3
        public void loadLevelViewTongBang3(ref string strTable, string strText,int NguonID,int TruongID)
        {
            strTable += "\n<tr>";
            //strTable += "\n<td align='center' class='cssTableReport' rowspan='6'>&nbsp;</td>";
            strTable += "\n<tr>";
            strTable += "\n<td valign=\"middle\" class=\"cssTableReport\" rowspan='5' align='center'>Tổng</td>";
            //Tong View
            #region "CRM"
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap' >&nbsp;</td>";
            //Lay du lieu theo can bo
            //L1
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang3_1.ToString() + "</td>";
            //L2
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang3_2.ToString() + "</td>";
            //L3
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang3_3.ToString() + "</td>";
            //L4
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang3_4.ToString() + "</td>";
            //L5A
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang3_5A.ToString() + "</td>";
            //L5B
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang3_5B.ToString() + "</td>";
            //L6
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang3_6.ToString() + "</td>";
            //L7
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang3_7.ToString() + "</td>";
            //L8
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang3_8.ToString() + "</td>";
            //L9
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsum_Bang3_9.ToString() + "</td>";
            //T
            int intsumT_CRM = intsum_Bang3_1 + intsum_Bang3_2 + intsum_Bang3_3 + intsum_Bang3_4 + intsum_Bang3_5A + intsum_Bang3_5B + intsum_Bang3_6 + intsum_Bang3_7 + intsum_Bang3_8 + intsum_Bang3_9;
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT_CRM.ToString() + "</td>";


            #endregion
            strTable += "\n</tr>";
            strTable += "\n<tr>";
            #region "So luong"
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Số lượng</td>";
            //Lay du lieu theo can bo
            //L1
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSL_Bang3_1.ToString() + "</td>";
            //L2
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSL_Bang3_2.ToString() + "</td>";
            //L3
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSL_Bang3_3.ToString() + "</td>";
            //L4
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSL_Bang3_4.ToString() + "</td>";
            //L5A
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSL_Bang3_5A.ToString() + "</td>";
            //L5B
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSL_Bang3_5B.ToString() + "</td>";
            //L6
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSL_Bang3_6.ToString() + "</td>";
            //L7
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSL_Bang3_7.ToString() + "</td>";
            //L8
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSL_Bang3_8.ToString() + "</td>";
            //L9
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSL_Bang3_9.ToString() + "</td>";
            //T
            int intsumT_SL = intsumSL_Bang3_1 + intsumSL_Bang3_2 + intsumSL_Bang3_3 + intsumSL_Bang3_4 + intsumSL_Bang3_5A + intsumSL_Bang3_5B + intsumSL_Bang3_6 + intsumSL_Bang3_7 + intsumSL_Bang3_8 + intsumSL_Bang3_9;
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT_SL.ToString() + "</td>";


            #endregion
            strTable += "\n</tr>";
            strTable += "\n<tr>";
            #region "So ton chua lam"
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Số tồn chưa làm</td>";
            //L1
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSTCL_Bang3_1.ToString() + "</td>";
            //L2
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSTCL_Bang3_2.ToString() + "</td>";
            //L3
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSTCL_Bang3_3.ToString() + "</td>";
            //L4
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSTCL_Bang3_4.ToString() + "</td>";
            //L5A
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSTCL_Bang3_5A.ToString() + "</td>";
            //L5B
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSTCL_Bang3_5B.ToString() + "</td>";
            //L6
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSTCL_Bang3_6.ToString() + "</td>";
            //L7
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSTCL_Bang3_7.ToString() + "</td>";
            //L8
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSTCL_Bang3_8.ToString() + "</td>";
            //L9
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumSTCL_Bang3_9.ToString() + "</td>";
            //T
            int intsumT_SCL = intsumSTCL_Bang3_1 + intsumSTCL_Bang3_2 + intsumSTCL_Bang3_3 + intsumSTCL_Bang3_4 + intsumSTCL_Bang3_5A + intsumSTCL_Bang3_5B + intsumSTCL_Bang3_6 + intsumSTCL_Bang3_7 + intsumSTCL_Bang3_8 + intsumSTCL_Bang3_9;
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumT_SCL.ToString() + "</td>";


            #endregion
            strTable += "\n</tr>";
            strTable += "\n<tr>";
            #region "So da lam chua len LV"
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Số đã làm chưa lên LV</td>";
            //L1
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumCLLV_Bang3_1.ToString() + "</td>";
            //L2
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumCLLV_Bang3_2.ToString() + "</td>";
            //L3
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumCLLV_Bang3_3.ToString() + "</td>";
            //L4
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumCLLV_Bang3_4.ToString() + "</td>";
            //L5A
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumCLLV_Bang3_5A.ToString() + "</td>";
            //L5B
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumCLLV_Bang3_5B.ToString() + "</td>";
            //L6
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumCLLV_Bang3_6.ToString() + "</td>";
            //L7
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumCLLV_Bang3_7.ToString() + "</td>";
            //L8
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intsumCLLV_Bang3_8.ToString() + "</td>";
            //L9
            strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intsumCLLV_Bang3_9.ToString() + "</td>";
            //T
            int intsumT_DLCLLV = intsumCLLV_Bang3_1 + intsumCLLV_Bang3_2 + intsumCLLV_Bang3_3 + intsumCLLV_Bang3_4 + intsumCLLV_Bang3_5A + intsumCLLV_Bang3_5B + intsumCLLV_Bang3_6 + intsumCLLV_Bang3_7 + intsumCLLV_Bang3_8 + intsumCLLV_Bang3_9;
            strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intsumT_DLCLLV.ToString() + "</td>";


            #endregion
            strTable += "\n</tr>";
            strTable += "\n<tr>";
            #region "So khong nen lam nua"
            strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>Số không nên làm nữa</td>";
            //L1
            strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intsumKNL_Bang3_1.ToString() + "</td>";
            //L2
            strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intsumKNL_Bang3_2.ToString() + "</td>";
            //L3
            strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intsumKNL_Bang3_3.ToString() + "</td>";
            //L4
            strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intsumKNL_Bang3_4.ToString() + "</td>";
            //L5A
            strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intsumKNL_Bang3_5A.ToString() + "</td>";
            //L5B
            strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intsumKNL_Bang3_5B.ToString() + "</td>";
            //L6
            strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intsumKNL_Bang3_6.ToString() + "</td>";
            //L7
            strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intsumKNL_Bang3_7.ToString() + "</td>";
            //L8
            strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intsumKNL_Bang3_8.ToString() + "</td>";
            //L9
            strTable += "\n<td class='cssTitleReport'  nowrap='nowrap' nowrap='nowrap'>" + intsumKNL_Bang3_9.ToString() + "</td>";

            //T
            int intsumT_KNL = intsumKNL_Bang3_1 + intsumKNL_Bang3_2 + intsumKNL_Bang3_3 + intsumKNL_Bang3_4 + intsumKNL_Bang3_5A + intsumKNL_Bang3_5B + intsumKNL_Bang3_6 + intsumKNL_Bang3_7 + intsumKNL_Bang3_8 + intsumKNL_Bang3_9;
            strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intsumT_KNL.ToString() + "</td>";

            #endregion
            strTable += "\n</tr>";

            strTable += "\n</tr>";
        }
        public void loadLevelTotal(ref string strTable, int intNguoiDungID, int NguonID,int TruongID)
        {
            //Lay du lieu theo nguoi dung
            DataTable dtDataByStaff = m_dtDataReport1.Clone();
            DataRow[] drDataTemp;
            drDataTemp = m_dtDataReport1.Select("NguoiDungID=" + intNguoiDungID.ToString());
            foreach (DataRow dr in drDataTemp)
            {
                dtDataByStaff.ImportRow(dr);
            }
            DataTable dtReportTemp = dtDataByStaff.Clone();
            DataRow[] drReceiverTemp;
            drReceiverTemp = dtDataByStaff.Select("LevelID=1");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            #region "Tong CRM"
            //Tong CRM
           // strTable += "\n<tr>";
            strTable += "\n<td style='width:22%;' class='cssTitleReport'  nowrap='nowrap'>CRM</td>";
            //LV1
            int intFirstL1 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 1, NguonID,TruongID);
            if (dtReportTemp != null && dtReportTemp.Rows.Count > 0)
            {
                int intLx1L1 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                int intLx2L1 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                int intLx3L1 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                int intEndL1 = intLx1L1 + intLx2L1 + intLx3L1;
                intCRM1 =  intFirstL1 - intEndL1;
                intsum_Bang3_1 = intsum_Bang3_1 + intCRM1;
                strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intCRM1.ToString() + "</td>";//L1
            }
            else
            {
                strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>0</td>";//L1
            }
           
            //LV2
            int intFirstL2 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 2, NguonID,TruongID);
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=2");
                foreach (DataRow dr in drReceiverTemp)
                {
                    dtReportTemp.ImportRow(dr);
                }
                if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
                {
                    int intLx1L2 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                    int intLx2L2 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                    int intLx3L2 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                    int intEndL2 = intLx1L2 + intLx2L2 + intLx3L2;
                    intCRM2 =  intFirstL2 - intEndL2;
                    intsum_Bang3_2 = intsum_Bang3_2 + intCRM2;
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intCRM2.ToString() + "</td>";//L2
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>0</td>";
                }
          
            //LV3
                int intFirstL3 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 3, NguonID,TruongID);
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=3");
                foreach (DataRow dr in drReceiverTemp)
                {
                    dtReportTemp.ImportRow(dr);
                }
                if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
                {
                    int intLx1L3 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                    int intLx2L3 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                    int intLx3L3 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                    int intEndL3 = intLx1L3 + intLx2L3 + intLx3L3;
                    intCRM3 = intFirstL3 - intEndL3 ;
                    intsum_Bang3_3 = intsum_Bang3_3 + intCRM3;
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intCRM3.ToString() + "</td>";//L2
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>0</td>";
                }
            //LV4
                int intFirstL4 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 4, NguonID, TruongID);
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=4");
                foreach (DataRow dr in drReceiverTemp)
                {
                    dtReportTemp.ImportRow(dr);
                }
                if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
                {
                    int intLx1L4 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                    int intLx2L4 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                    int intLx3L4 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                    int intEndL4 = intLx1L4 + intLx2L4 + intLx3L4;
                    intCRM4 =  intFirstL4 -intEndL4;
                    intsum_Bang3_4 = intsum_Bang3_4 + intCRM4;
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intCRM4.ToString() + "</td>";//L2
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>0</td>";
                }
            //LV5A
                int intFirstL5A = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 5, NguonID, TruongID);
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=5");
                foreach (DataRow dr in drReceiverTemp)
                {
                    dtReportTemp.ImportRow(dr);
                }
                if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
                {
                    int intLx1L5A = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                    int intLx2L5A = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                    int intLx3L5A = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                    int intEndL5A = intLx1L5A + intLx2L5A + intLx3L5A;
                    intCRM5A = intFirstL5A - intEndL5A;
                    intsum_Bang3_5A = intsum_Bang3_5A + intCRM5A;
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intCRM5A.ToString() + "</td>";//L2
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>0</td>";
                }
            //Lv5B
                int intFirstL5B = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 6, NguonID, TruongID);
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=6");
                foreach (DataRow dr in drReceiverTemp)
                {
                    dtReportTemp.ImportRow(dr);
                }
                if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
                {
                    int intLx1L5B = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                    int intLx2L5B = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                    int intLx3L5B = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                    int intEndL5B = intLx1L5B + intLx2L5B + intLx3L5B;
                    intCRM5B = intFirstL5B - intEndL5B;
                    intsum_Bang3_5B = intsum_Bang3_5B + intCRM5B;
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intCRM5B.ToString() + "</td>";//L2
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>0</td>";
                }
            //Lv6
                int intFirstL6 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 7, NguonID, TruongID);
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=7");
                foreach (DataRow dr in drReceiverTemp)
                {
                    dtReportTemp.ImportRow(dr);
                }
                if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
                {
                    int intLx1L6 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                    int intLx2L6 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                    int intLx3L6 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                    int intEndL6 = intLx1L6 + intLx2L6 + intLx3L6;
                    intCRM6 = intFirstL6 - intEndL6;
                    intsum_Bang3_6 = intsum_Bang3_6 + intCRM6;
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intCRM6.ToString() + "</td>";//L2
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>0</td>";
                }
            //Lv7
                int intFirstL7 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 8, NguonID, TruongID);
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=8");
                foreach (DataRow dr in drReceiverTemp)
                {
                    dtReportTemp.ImportRow(dr);
                }
                if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
                {
                    int intLx1L7 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                    int intLx2L7 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                    int intLx3L7 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                    int intEndL7 = intLx1L7 + intLx2L7 + intLx3L7;
                    intCRM7 = intFirstL7 - intEndL7;
                    intsum_Bang3_7 = intsum_Bang3_7 + intCRM7;
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intCRM7.ToString() + "</td>";//L2
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>0</td>";
                }
            //Lv8
                int intFirstL8 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 9, NguonID, TruongID);
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=9");
                foreach (DataRow dr in drReceiverTemp)
                {
                    dtReportTemp.ImportRow(dr);
                }
                if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
                {
                    int intLx1L8 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                    int intLx2L8 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                    int intLx3L8 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                    int intEndL8 = intLx1L8 + intLx2L8 + intLx3L8;
                    intCRM8 =  intFirstL8 - intEndL8;
                    intsum_Bang3_8 = intsum_Bang3_8 + intCRM8;
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intCRM8.ToString() + "</td>";//L2
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>0</td>";
                }
             //LV9
                int intFirstL9 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 10, NguonID, TruongID);
                dtReportTemp.Clear();
                drReceiverTemp = dtDataByStaff.Select("LevelID=10");
                foreach (DataRow dr in drReceiverTemp)
                {
                    dtReportTemp.ImportRow(dr);
                }
                if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
                {
                    int intLx1L9 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                    int intLx2L9 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                    int intLx3L9 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                    int intEndL9 = intLx1L9 + intLx2L9 + intLx3L9;
                    intCRM9 = intFirstL9 - intEndL9;
                    intsum_Bang3_9 = intsum_Bang3_9 + intCRM9;
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intCRM9.ToString() + "</td>";//L2
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
                }
            //T
                int TotalCRM = + intCRM1 + intCRM2 + intCRM3 + intCRM4 + intCRM5A + intCRM5B+ intCRM6 + intCRM7 + intCRM8 + intCRM9;
                if (TotalCRM != 0)
                {
                    strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + TotalCRM.ToString() + "</td>";
                }
                else
                {
                    strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
                }
            strTable += "\n</tr>";
            #endregion
            #region "Tong So Luong"
            //Tong So luong

            strTable += "\n<tr>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Số lượng</td>";
            //Lv1
            int intL1 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 1, NguonID, TruongID);
            int intL2 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 2, NguonID, TruongID);
            int intL3 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 3, NguonID, TruongID);
            int intL4 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 4, NguonID, TruongID);
            int intL5A = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 5, NguonID, TruongID);
            int intL5B = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 6, NguonID, TruongID);
            int intL6 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 7, NguonID, TruongID);
            int intL7 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 8, NguonID, TruongID);
            int intL8 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 9, NguonID, TruongID);
            //Tong LV1
            int intFirstSL1 = intL1 + intL2 + intL3 + intL4 + intL5A + intL5B + intL6 + intL7 + intL8;
            int intSLT1 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=1");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSL1 = Convert.ToInt32(dtReportTemp.Rows[0]["SLT"].ToString());
                intSLT1 = intFirstSL1 - intEndSL1;
                intsumSL_Bang3_1 = intsumSL_Bang3_1 + intSLT1;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSLT1.ToString() + "</td>";//L2
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv2
            int intFirstSL2 = intFirstSL1 - intL1;
            int intSLT2 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=2");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSL2 = Convert.ToInt32(dtReportTemp.Rows[0]["SLT"].ToString());
                intSLT2 = intFirstSL2 - intEndSL2;
                intsumSL_Bang3_2 = intsumSL_Bang3_2 + intSLT2;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSLT2.ToString() + "</td>";//L2
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv3
            int intFirstSL3 = intFirstSL2 - intL2;
            int intSLT3 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=3");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSL3 = Convert.ToInt32(dtReportTemp.Rows[0]["SLT"].ToString());
                intSLT3 = intFirstSL3 - intEndSL3;
                intsumSL_Bang3_3 = intsumSL_Bang3_3 + intSLT3;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSLT3.ToString() + "</td>";//L2
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv4
            int intFirstSL4 = intFirstSL3 - intL3;
            int intSLT4 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=4");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSL4 = Convert.ToInt32(dtReportTemp.Rows[0]["SLT"].ToString());
                intSLT4 = intFirstSL4 - intEndSL4 ;
                intsumSL_Bang3_4 = intsumSL_Bang3_4 + intSLT4;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSLT4.ToString() + "</td>";//L2
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv5A
            int intFirstSL5A = intFirstSL4 - intL4;
            int intSLT5A = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=5");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSL5A = Convert.ToInt32(dtReportTemp.Rows[0]["SLT"].ToString());
                intSLT5A = intFirstSL5A - intEndSL5A;
                intsumSL_Bang3_5A = intsumSL_Bang3_5A + intSLT5A;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSLT5A.ToString() + "</td>";//L2
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
           
            //Lv5B
            int intFirstSL5B = intFirstSL5A - intL5A;
            int intSLT5B = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=6");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSL5B = Convert.ToInt32(dtReportTemp.Rows[0]["SLT"].ToString());
                intSLT5B = intFirstSL5B - intEndSL5B;
                intsumSL_Bang3_5B = intsumSL_Bang3_5B + intSLT5B;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSLT5B.ToString() + "</td>";//L2
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //LV6
            int intFirstSL6 = intFirstSL5B - intL5B;
            int intSLT6 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=7");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSL6 = Convert.ToInt32(dtReportTemp.Rows[0]["SLT"].ToString());
                intSLT6 = intFirstSL6 - intEndSL6;
                intsumSL_Bang3_6 = intsumSL_Bang3_6 + intSLT6;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSLT6.ToString() + "</td>";//L2
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
          
            //LV7
            int intFirstSL7 = intFirstSL6 - intL6;
            int intSLT7 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=8");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSL7 = Convert.ToInt32(dtReportTemp.Rows[0]["SLT"].ToString());
                intSLT7 = intFirstSL7 - intEndSL7;
                intsumSL_Bang3_7 = intsumSL_Bang3_7 + intSLT7;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSLT7.ToString() + "</td>";//L2
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //LV8
            int intFirstSL8 = intFirstSL7 - intL7;
            int intSLT8 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=9");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSL8 = Convert.ToInt32(dtReportTemp.Rows[0]["SLT"].ToString());
                intSLT8 = intFirstSL8 - intEndSL8 ;
                intsumSL_Bang3_8 = intsumSL_Bang3_8 + intSLT8;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSLT8.ToString() + "</td>";//L2
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //LV9
            //int intL9 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungID, 1);
            int intFirstSL9 = intFirstSL8 - intL8;
            int intSLT9 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=10");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSL9 = Convert.ToInt32(dtReportTemp.Rows[0]["SLT"].ToString());
                intSLT9 = intFirstSL9 - intEndSL9;
                intsumSL_Bang3_9 = intsumSL_Bang3_9 + intSLT9;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSLT9.ToString() + "</td>";//L2
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
           
            
            //Tong SL
            int TotalSL = intSLT1 + intSLT2 + intSLT3 + intSLT4 + intSLT5A + intSLT5B + intSLT6 + intSLT7 + intSLT8 + intSLT9;
            if (TotalSL != 0)
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + TotalSL.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }

            strTable += "\n</tr>";
            #endregion
            
            #region "Tong So ton Chua lam"
            //*Tong So ton chua lam*
            strTable += "\n<tr>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Số tồn chưa làm</td>";
            //Lv1
            int intFirstSTCL1 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 1, 1, NguonID, TruongID);
            int intSTCL1 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=1");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSTCL1 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                intSTCL1 = intFirstSTCL1 - intEndSTCL1;
                intsumSTCL_Bang3_1 = intsumSTCL_Bang3_1 + intSTCL1;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSTCL1.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv2
            int intFirstSTCL2 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 2, 1, NguonID, TruongID);
            int intSTCL2 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=2");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSTCL2 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                intSTCL2 = intFirstSTCL2- intEndSTCL2;
                intsumSTCL_Bang3_2 = intsumSTCL_Bang3_2 + intSTCL2;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSTCL2.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv3
            int intFirstSTCL3 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 3, 1, NguonID, TruongID);
            int intSTCL3 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=3");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSTCL3 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                intSTCL3 = intFirstSTCL3 - intEndSTCL3 ;
                intsumSTCL_Bang3_3 = intsumSTCL_Bang3_3 + intSTCL3;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSTCL3.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv4
            int intFirstSTCL4 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 4, 1, NguonID, TruongID);
            int intSTCL4 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=4");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSTCL4 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                intSTCL4 = intFirstSTCL4 - intEndSTCL4;
                intsumSTCL_Bang3_4 = intsumSTCL_Bang3_4 + intSTCL4;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSTCL4.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv5A
            int intFirstSTCL5A = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 5, 1, NguonID, TruongID);
            int intSTCL5A = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=5");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSTCL5A = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                intSTCL5A = intFirstSTCL5A - intEndSTCL5A ;
                intsumSTCL_Bang3_5A = intsumSTCL_Bang3_5A + intSTCL5A;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSTCL5A.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv5B
            int intFirstSTCL5B = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 6, 1, NguonID, TruongID);
            int intSTCL5B = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=6");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSTCL5B = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                intSTCL5B = intFirstSTCL5B - intEndSTCL5B ;
                intsumSTCL_Bang3_5B = intsumSTCL_Bang3_5B + intSTCL5B;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSTCL5B.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //LV6
            int intFirstSTCL6 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 7, 1, NguonID, TruongID);
            int intSTCL6 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=7");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSTCL6 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                intSTCL6 = intFirstSTCL6 - intEndSTCL6 ;
                intsumSTCL_Bang3_6 = intsumSTCL_Bang3_6 + intSTCL6;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSTCL6.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //LV7
            int intFirstSTCL7 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 8, 1, NguonID, TruongID);
            int intSTCL7 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=8");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSTCL7 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                intSTCL7 = intFirstSTCL7 - intEndSTCL7 ;
                intsumSTCL_Bang3_7 = intsumSTCL_Bang3_7 + intSTCL7;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSTCL7.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //LV8
            int intFirstSTCL8 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 9, 1, NguonID, TruongID);
            int intSTCL8 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=9");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSTCL8 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                intSTCL8 = intFirstSTCL8 - intEndSTCL8 ;
                intsumSTCL_Bang3_8 = intsumSTCL_Bang3_8 + intSTCL8;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSTCL8.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //LV9
            int intFirstSTCL9 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 10, 1, NguonID, TruongID);
            int intSTCL9 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=10");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndSTCL9 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx1"].ToString());
                intSTCL9 = intFirstSTCL9 - intEndSTCL9;
                intsumSTCL_Bang3_9 = intsumSTCL_Bang3_9 + intSTCL9;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intSTCL9.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Tong SL
            int TotalSTCL = intSTCL1 + intSTCL2 + intSTCL3 + intSTCL4 + intSTCL5A + intSTCL5B + intSTCL6 + intSTCL7 + intSTCL8 + intSTCL9;
            if (TotalSTCL != 0)
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + TotalSTCL.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            strTable += "\n</tr>";
            #endregion
            #region "Tong so da lam chua len Level"
            //Tong So da lam chua len Level
            strTable += "\n<tr>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Số đã làm chưa lên Level</td>";
            //Lv1
            int intFirstCLLV1 = objHocVien.loadDemSoHocVienTheoThaiGoiByReport23(intNguoiDungID, 1, intTrangThaiGoi2, NguonID, TruongID);
            int intCLLV1 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=1");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndCLLV1 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                intCLLV1 = intFirstCLLV1 - intEndCLLV1 ;
                intsumCLLV_Bang3_1 = intsumCLLV_Bang3_1 + intCLLV1;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCLLV1.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv2
            int intFirstCLLV2 = objHocVien.loadDemSoHocVienTheoThaiGoiByReport23(intNguoiDungID, 2, intTrangThaiGoi2, NguonID, TruongID);
            int intCLLV2 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=2");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndCLLV2 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                intCLLV2 = intFirstCLLV2 - intEndCLLV2;
                intsumCLLV_Bang3_2 = intsumCLLV_Bang3_2 + intCLLV2;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCLLV2.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv3
            int intFirstCLLV3 = objHocVien.loadDemSoHocVienTheoThaiGoiByReport23(intNguoiDungID, 3, intTrangThaiGoi2, NguonID, TruongID);
            int intCLLV3 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=3");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndCLLV3 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                intCLLV3 = intFirstCLLV3 - intEndCLLV3;
                intsumCLLV_Bang3_3 = intsumCLLV_Bang3_3 + intCLLV3;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCLLV3.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv4
            int intFirstCLLV4 = objHocVien.loadDemSoHocVienTheoThaiGoiByReport23(intNguoiDungID, 4, intTrangThaiGoi2, NguonID, TruongID);
            int intCLLV4 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=4");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndCLLV4 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                intCLLV4 = intFirstCLLV4 - intEndCLLV4;
                intsumCLLV_Bang3_4 = intsumCLLV_Bang3_4 + intCLLV4;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCLLV4.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv5A
            int intFirstCLLV5A = objHocVien.loadDemSoHocVienTheoThaiGoiByReport23(intNguoiDungID, 5, intTrangThaiGoi2, NguonID, TruongID);
            int intCLLV5A = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=5");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndCLLV5A = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                intCLLV5A = intFirstCLLV5A - intEndCLLV5A ;
                intsumCLLV_Bang3_5A = intsumCLLV_Bang3_5A + intCLLV5A;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCLLV5A.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv5B
            int intFirstCLLV5B = objHocVien.loadDemSoHocVienTheoThaiGoiByReport23(intNguoiDungID, 6, intTrangThaiGoi2, NguonID, TruongID);
            int intCLLV5B = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=6");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndCLLV5B = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                intCLLV5B = intFirstCLLV5B - intEndCLLV5B ;
                intsumCLLV_Bang3_5B = intsumCLLV_Bang3_5B + intCLLV5B;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCLLV5B.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //LV6
            int intFirstCLLV6 = objHocVien.loadDemSoHocVienTheoThaiGoiByReport23(intNguoiDungID, 7, intTrangThaiGoi2, NguonID, TruongID);
            int intCLLV6 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=7");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndCLLV6 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                intCLLV6 = intFirstCLLV6 - intEndCLLV6 ;
                intsumCLLV_Bang3_6 = intsumCLLV_Bang3_6 + intCLLV6;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCLLV6.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //LV7
            int intFirstCLLV7 = objHocVien.loadDemSoHocVienTheoThaiGoiByReport23(intNguoiDungID, 8, intTrangThaiGoi2, NguonID, TruongID);
            int intCLLV7 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=8");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndCLLV7 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                intCLLV7 = intFirstCLLV7 - intEndCLLV7 ;
                intsumCLLV_Bang3_7 = intsumCLLV_Bang3_7 + intCLLV7;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intCLLV7.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //LV8
            int intFirstCLLV8 = objHocVien.loadDemSoHocVienTheoThaiGoiByReport23(intNguoiDungID, 9, intTrangThaiGoi2, NguonID, TruongID);
            int intCLLV8 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=9");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndCLLV8 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                intCLLV8 = intFirstCLLV8 - intEndCLLV8 ;
                intsumCLLV_Bang3_8 = intsumCLLV_Bang3_8 + intCLLV8;
                strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intCLLV8.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //LV9
            int intFirstCLLV9 = objHocVien.loadDemSoHocVienTheoThaiGoiByReport23(intNguoiDungID, 10, intTrangThaiGoi2, NguonID, TruongID);
            int intCLLV9 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=9");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndCLLV9 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx2"].ToString());
                intCLLV9 = intFirstCLLV9 - intEndCLLV9;
                intsumCLLV_Bang3_9 = intsumCLLV_Bang3_9 + intCLLV9;
                strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + intCLLV9.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Tong TotalCLLV
            int TotalCLLV = intCLLV1 + intCLLV2 + intCLLV3 + intCLLV4 + intCLLV5A + intCLLV5B + intCLLV6 + intCLLV7 + intCLLV8 + intCLLV9;
            if (TotalCLLV != 0)
            {
                strTable += "\n<td class='cssTitleReport'  nowrap='nowrap'>" + TotalCLLV.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            strTable += "\n</tr>";
            #endregion
            #region "Tong so khong nen lam nua"
            //Tong So khong len lam nua
            strTable += "\n<tr>";
            strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>Số không nên làm nữa</td>";
            //Lv1
            int intFirstKNL1 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 1, 8, NguonID, TruongID);
            int intKNL1 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=1");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndKNL1 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                intKNL1 = intFirstKNL1 - intEndKNL1;
                intsumKNL_Bang3_1 = intsumKNL_Bang3_1 + intKNL1;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intKNL1.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv2
            int intFirstKNL2 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 2, 8, NguonID, TruongID);
            int intKNL2 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=2");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndKNL2 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                intKNL2 = intFirstKNL2 - intEndKNL2 ;
                intsumKNL_Bang3_2 = intsumKNL_Bang3_2 + intKNL2;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intKNL2.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv3
            int intFirstKNL3 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 3, 8, NguonID, TruongID);
            int intKNL3 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=3");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndKNL3 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                intKNL3 = intFirstKNL3 - intEndKNL3 ;
                intsumKNL_Bang3_3 = intsumKNL_Bang3_3 + intKNL3;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intKNL3.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv4
            int intFirstKNL4 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 4, 8, NguonID, TruongID);
            int intKNL4 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=4");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndKNL4 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                intKNL4 = intFirstKNL4 - intEndKNL4 ;
                intsumKNL_Bang3_4 = intsumKNL_Bang3_4 + intKNL4;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intKNL4.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv5A
            int intFirstKNL5A = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 5, 8, NguonID, TruongID);
            int intKNL5A = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=5");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndKNL5A = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                intKNL5A = intFirstKNL5A -  intEndKNL5A ;
                intsumKNL_Bang3_5A = intsumKNL_Bang3_5A + intKNL5A;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intKNL5A.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Lv5B
            int intFirstKNL5B = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 6, 8, NguonID, TruongID);
            int intKNL5B = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=6");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndKNL5B = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                intKNL5B = intFirstKNL5B - intEndKNL5B ;
                intsumKNL_Bang3_5B = intsumKNL_Bang3_5B + intKNL5B;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intKNL5B.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //LV6
            int intFirstKNL6 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 7, 8, NguonID, TruongID);
            int intKNL6 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=7");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndKNL6 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                intKNL6 = intFirstKNL6- intEndKNL6  ;
                intsumKNL_Bang3_6 = intsumKNL_Bang3_6 + intKNL6;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intKNL6.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //LV7
            int intFirstKNL7 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 8, 8, NguonID, TruongID);
            int intKNL7 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=8");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndKNL7 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                intKNL7 =intFirstKNL7- intEndKNL7 ;
                intsumKNL_Bang3_7 = intsumKNL_Bang3_7 + intKNL7;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intKNL7.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //LV8
            int intFirstKNL8 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 9, 8, NguonID, TruongID);
            int intKNL8 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=9");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndKNL8 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                intKNL8 = intFirstKNL8 - intEndKNL8;
                intsumKNL_Bang3_8 = intsumKNL_Bang3_8 + intKNL8;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intKNL8.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //LV9
            int intFirstKNL9 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 10, 8, NguonID, TruongID);
            int intKNL9 = 0;
            dtReportTemp.Clear();
            drReceiverTemp = dtDataByStaff.Select("LevelID=10");
            foreach (DataRow dr in drReceiverTemp)
            {
                dtReportTemp.ImportRow(dr);
            }
            if (dtReportTemp.Rows.Count > 0 && dtReportTemp.Rows != null)
            {
                int intEndKNL9 = Convert.ToInt32(dtReportTemp.Rows[0]["Lx3"].ToString());
                intKNL9 = intFirstKNL9 - intEndKNL9;
                intsumKNL_Bang3_9 = intsumKNL_Bang3_9 + intKNL9;
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + intKNL9.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            //Tong TotalKNL
            int TotalKNL = intKNL1 + intKNL2 + intKNL3 + intKNL4 + intKNL5A + intKNL5B + intKNL6 + intKNL7 + intKNL8 + intKNL9;
            if (TotalKNL != 0)
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>" + TotalKNL.ToString() + "</td>";
            }
            else
            {
                strTable += "\n<td class='cssTitleReport' nowrap='nowrap'>0</td>";
            }
            strTable += "\n</tr>";
            #endregion

        }
        public void loadReportTotal(ref string strTable, int NguonID ,int TruongID)
        {
            strTable += "<table cellpadding='2' cellspacing='0' class='cssTableReport'>";
            strTable += "\n<tr>";
            strTable += "\n<td class='cssReport23Title1'>TVTS</td>";
            strTable += "\n<td style='width:50%;' class='cssReport23Title1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            strTable += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            strTable += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            strTable += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
            strTable += "\n<td style='width:8%;' class='cssReport23Title1'>L1</td>";
            strTable += "\n<td style='width:8%;' class='cssReport23Title1'>L2</td>";
            strTable += "\n<td style='width:8%;'class='cssReport23Title1'>L3</td>";
            strTable += "\n<td style='width:8%;' class='cssReport23Title1'>L4</td>";
            strTable += "\n<td style='width:8%;' class='cssReport23Title1'>L5A</td>";

            strTable += "\n<td style='width:8%;' class='cssReport23Title1'>L5B</td>";
            strTable += "\n<td style='width:8%;' class='cssReport23Title1'>L6</td>";
            strTable += "\n<td style='width:8%;' class='cssReport23Title1'>L7</td>";

            strTable += "\n<td style='width:8%;' class='cssReport23Title1'>L8</td>";
            strTable += "\n<td style='width:8%;' class='cssReport23Title1'>L9</td>";
            strTable += "\n<td style='width:8%;' class='cssReport23Title1'>T</td>";
            strTable += "\n</tr>";
            loadQuyenNhomReportTotal(ref strTable, 4, NguonID, TruongID);
            strTable += "\n</table>";
        }
        private void loadHistoryDate(int NguonID,int TruongID)
        {
            DataTable dtData = new DataTable();
            dtData = objReport.getHistoryDate23STruong(NguonID,TruongID);
            if (dtData != null && dtData.Rows.Count > 0)
            {
                BindData.bindDropDownList(this.ddlHistory, dtData, "Date", "Ngay");
                this.ddlHistory.SelectedIndex = 0;
            }
        }
        #endregion
      
        //Export
        #region "Export Excel"

        public string loadExportReport23STruong()
        {
            int intNguonID = Convert.ToInt32(this.ddlNguon.SelectedValue);
            int intTruongID = Convert.ToInt32(this.ddlTruong.SelectedValue);
            try
            {
                string strHTML = "<html xmlns:o=\"urn:schemas-microsoft-com:office:office\" ";
                strHTML += "\n xmlns:x=\"urn:schemas-microsoft-com:office:excel\" ";
                strHTML += "\n xmlns=\"http://www.w3.org/TR/REC-html40\"> ";
                strHTML += "\n <head> ";
                strHTML += "\n <meta http-equiv=Content-Type content=\"text/html; charset=UTF-8\"> ";
                strHTML += "\n <meta name=ProgId content=Excel.Sheet> ";
                strHTML += "\n <meta name=Generator content=\"Microsoft Excel 11\"> ";
                strHTML += "\n <link rel=File-List ";
                strHTML += "\n href=\"New%20Microsoft%20Excel%20Worksheet_files/filelist.xml\"> ";
                strHTML += "\n <link rel=Edit-Time-Data ";
                strHTML += "\n href=\"New%20Microsoft%20Excel%20Worksheet_files/editdata.mso\"> ";
                strHTML += "\n <link rel=OLE-Object-Data ";
                strHTML += "\n href=\"New%20Microsoft%20Excel%20Worksheet_files/oledata.mso\"> ";
                strHTML += "\n <!--[if gte mso 9]><xml> ";
                strHTML += "\n  <o:DocumentProperties> ";
                strHTML += "\n   <o:LastAuthor>User</o:LastAuthor> ";
                strHTML += "\n   <o:Created>1996-10-14T23:33:28Z</o:Created> ";
                strHTML += "\n   <o:LastSaved>2009-06-04T09:49:20Z</o:LastSaved> ";
                strHTML += "\n   <o:Version>11.5606</o:Version> ";
                strHTML += "\n </o:DocumentProperties> ";
                strHTML += "\n </xml><![endif]--> ";
                strHTML += "\n <style> ";
                strHTML += "\n <!--table ";
                strHTML += "\n      {mso-displayed-decimal-separator:\"\\.\"; ";
                strHTML += "\n      mso-displayed-thousand-separator:\"\\,\";} ";
                strHTML += "\n @page ";
                strHTML += "\n      {margin:1.0in .75in 1.0in .75in; ";
                strHTML += "\n      mso-header-margin:.5in; ";
                strHTML += "\n 	mso-footer-margin:.5in;} ";
                strHTML += "\n tr ";
                strHTML += "\n 	{mso-height-source:auto;} ";
                strHTML += "\n col ";
                strHTML += "\n 	{mso-width-source:auto;} ";
                strHTML += "\n br ";
                strHTML += "\n 	{mso-data-placement:same-cell;} ";
                strHTML += "\n .style0 ";
                strHTML += "\n 	{mso-number-format:General; ";
                strHTML += "\n 	text-align:general; ";
                strHTML += "\n 	vertical-align:bottom; ";
                strHTML += "\n 	white-space:nowrap; ";
                strHTML += "\n 	mso-rotate:0; ";
                strHTML += "\n 	mso-background-source:auto; ";
                strHTML += "\n 	mso-pattern:auto; ";
                strHTML += "\n 	color:windowtext; ";
                strHTML += "\n 	font-size:10.0pt; ";
                strHTML += "\n 	font-weight:400; ";
                strHTML += "\n 	font-style:normal; ";
                strHTML += "\n 	text-decoration:none; ";
                strHTML += "\n 	font-family:Arial; ";
                strHTML += "\n 	mso-generic-font-family:auto; ";
                strHTML += "\n 	mso-font-charset:0; ";
                strHTML += "\n 	border:none; ";
                strHTML += "\n 	mso-protection:locked visible; ";
                strHTML += "\n 	mso-style-name:Normal; ";
                strHTML += "\n 	mso-style-id:0;} ";
                strHTML += "\n td ";
                strHTML += "\n 	{mso-style-parent:style0; ";
                strHTML += "\n 	padding-top:1px; ";
                strHTML += "\n 	padding-right:1px; ";
                strHTML += "\n 	padding-left:1px; ";
                strHTML += "\n 	mso-ignore:padding; ";
                strHTML += "\n 	color:windowtext; ";
                strHTML += "\n 	font-size:10.0pt; ";
                strHTML += "\n 	font-weight:400; ";
                strHTML += "\n 	font-style:normal; ";
                strHTML += "\n 	text-decoration:none; ";
                strHTML += "\n 	font-family:Arial; ";
                strHTML += "\n 	mso-generic-font-family:auto; ";
                strHTML += "\n 	mso-font-charset:0; ";
                strHTML += "\n 	mso-number-format:General; ";
                strHTML += "\n 	text-align:general; ";
                strHTML += "\n 	vertical-align:bottom; ";
                strHTML += "\n 	border:none; ";
                strHTML += "\n 	mso-background-source:auto; ";
                strHTML += "\n 	mso-pattern:auto; ";
                strHTML += "\n 	mso-protection:locked visible; ";
                strHTML += "\n 	white-space:nowrap; ";
                strHTML += "\n 	mso-rotate:0;} ";

                strHTML += ".cssTitleReport"
                + " {   mso-style-parent:style0; "
                + " font-size:11px;"
                + " font-family:Tahoma, sans-serif;"
                + " mso-font-charset:0;"
                + " font-weight:bold;"
                + " border-top:1.0pt solid black;"
                + " border-left:1.0pt solid black;"
                + " border-right:1.0pt solid black;"
                + " border-bottom:1.0pt solid black;"
                + " background:white;"
                + " mso-pattern:auto none;}";
                strHTML += ".cssReport23Title1"
                + " {  mso-style-parent:style0; "
                + " border-top:1.0pt solid black;"
                + " border-left:1.0pt solid black;"
                + " border-right:1.0pt solid black;"
                + " border-bottom:1.0pt solid black;"
                + " font-size:12px;"
                + " font-family:Tahoma, sans-serif;"
                + " mso-font-charset:0;"
                + " color:#FFFFFF;"
                + " background-color:#800000;"
                + " font-weight:bold;text-align:center;vertical-align:middle;"
                + " mso-pattern:auto none;}";
                strHTML += ".cssReport23Title2"
             + " {  mso-style-parent:style0; "
             + " border-top:1.0pt solid black;"
             + " border-left:1.0pt solid black;"
             + " border-right:1.0pt solid black;"
             + " border-bottom:1.0pt solid black;"
             + " font-size:12px;"
             + " font-family:Tahoma, sans-serif;"
             + " mso-font-charset:0;"
             + " color:#000000;"
             + " font-weight:bold;text-align:center;vertical-align:middle;"
             + " mso-pattern:auto none;}";
                strHTML += ".cssLabelTitle"
                + "{ font-family:Tahoma, sans-serif;"
                + " font-size: 11px"
                + " border-top:1.0pt solid black;"
                + " border-left:1.0pt solid black;"
                + " border-right:1.0pt solid black;"
                + " border-bottom:1.0pt solid black;"
                + " font-weight:bold;text-align:center;vertical-align:middle;"
                + " mso-pattern:auto none;}";
                strHTML += ".cssPercentReport"
                + "{ font-family:Tahoma, sans-serif;"
                + " font-size: 11px"
                + " color:#000000;"
                + " border-top:1.0pt solid black;"
                + " border-left:1.0pt solid black;"
                + " border-right:1.0pt solid black;"
                + " border-bottom:1.0pt solid black;"
                + " font-weight:bold;text-align:center;vertical-align:middle;"
                + " mso-pattern:auto none;}";
                
                strHTML += ".cssTableReport"
                + " {  mso-style-parent:style0; "
                + " border-top:1.0pt solid black;"
                + " border-left:1.0pt solid black;"
                + " border-right:1.0pt solid black;"
                + " border-bottom:1.0pt solid black;"
                + " font-family:Tahoma, sans-serif;"
                + " mso-font-charset:0;"
                + " font-weight:bold;text-align:center;vertical-align:middle;"
                + " mso-pattern:auto none;}";

                //strHTML += ".cssPercentReport"
                // + "{ font-family:Tahoma, sans-serif;"
                // + " font-size: 11px;"
                // + "  border: 1px #000000 solid;"
                // + " color:#000000;"
                // + " font-weight:bold;text-align:center;vertical-align:middle;}";

                 //strHTML += ".cssTitleReport4s"
                 //+ "{ font-family:Verdana, sans-serif;"
                 //+ " font-size: 12px;"
                 //+ " color:#000000;"
                 //+ " font-weight:bold;text-align:center;vertical-align:middle;}";
                 //strHTML += ".cssReport4sTitle1"
                 //+ "{ font-family:Verdana, sans-serif;"
                 //+ " font-size: 12px;"
                 //+ " color:#000000;"
                 //+ " font-weight:bold;text-align:center;vertical-align:middle;}";
                

                 //strHTML += ".cssLabelReport"
                 // + "{ font-family: tahoma,Arial,Times New Roman"
                 // + " font-size: 18px;"
                 // + " border: 1px #000000 solid;"
                 // + " color:#000000;"
                 // + " background-color:#800000;"
                 // + " font-weight:bold;text-align:center;vertical-align:middle;}";


                //+ "{font-family: tahoma; font-size: 11px;font-weight:bold;border: 1px #000000 solid;text-align:left;}"
               // + ".cssTitleReport2"
               // + "{font-family: tahoma; font-size: 14px;font-weight:bold;text-align:center;vertical-align:middle;}"
               // + ".cssTableReport"
               // + "{border: 1px #000000 solid;font-family: tahoma;text-align:center;vertical-align:middle;}"
                //+ ".cssLabelTitle"
                //+ "{font-family: tahoma;font-size: 12px;font-weight:bold;bold;text-align:center;vertical-align:middle;}"

                //+ ".cssPercentReport"
                //+ "{color:#0000FF;font-family: tahoma;font-size: 11px; text-decoration:none; border: 1px #000000 solid;bold;text-align:center;vertical-align:middle;}"
                //+ ".cssTitleReport4s"
                //+ "{font-family: Verdana; font-size: 11px;font-weight:bold;color:#000000;bold;text-align:center;vertical-align:middle;}"
                //+ ".cssReport4sTitle1"
                //+ "{font-family: tahoma; font-size: 12px;font-weight:bold;bold;text-align:center;vertical-align:middle;}"

                //+ ".cssReport23Title1"
                //+ "{color:#FFFFFF;background-color:#800000;font-family: tahoma,Arial,Times New Roman; font-size: 12px;font-weight:bold;border: 1px #000000 solid;}"
                //+ ".cssReport4sTitle2"
                //+ "{font-family: tahoma; font-size: 11px;font-weight:bold;bold;text-align:center;vertical-align:middle;}"
                //+ ".cssLabelReport"
                //+ "{color:#000000;font-family: tahoma,Arial,Times New Roman; font-size: 18px;font-weight:bold;bold;text-align:center;vertical-align:middle;}";
                strHTML += "\n </style> ";

                strHTML += "\n <!--[if gte mso 9]><xml> ";
                strHTML += "\n  <x:ExcelWorkbook> ";
                strHTML += "\n   <x:ExcelWorksheets> ";
                strHTML += "\n    <x:ExcelWorksheet> ";
                strHTML += "\n     <x:Name>Sheet1</x:Name> ";
                strHTML += "\n     <x:WorksheetOptions> ";
                strHTML += "\n      <x:Selected/> ";
                strHTML += "\n      <x:Panes> ";
                strHTML += "\n       <x:Pane> ";
                strHTML += "\n        <x:Number>3</x:Number> ";
                strHTML += "\n        <x:ActiveRow>2</x:ActiveRow> ";
                strHTML += "\n        <x:ActiveCol>3</x:ActiveCol> ";
                strHTML += "\n       </x:Pane> ";
                strHTML += "\n      </x:Panes> ";
                strHTML += "\n      <x:ProtectContents>False</x:ProtectContents> ";
                strHTML += "\n      <x:ProtectObjects>False</x:ProtectObjects> ";
                strHTML += "\n      <x:ProtectScenarios>False</x:ProtectScenarios> ";
                strHTML += "\n     </x:WorksheetOptions> ";
                strHTML += "\n    </x:ExcelWorksheet> ";
                strHTML += "\n    <x:ExcelWorksheet> ";
                strHTML += "\n     <x:Name>Sheet2</x:Name> ";
                strHTML += "\n     <x:WorksheetOptions> ";
                strHTML += "\n      <x:ProtectContents>False</x:ProtectContents> ";
                strHTML += "\n      <x:ProtectObjects>False</x:ProtectObjects> ";
                strHTML += "\n      <x:ProtectScenarios>False</x:ProtectScenarios> ";
                strHTML += "\n     </x:WorksheetOptions> ";
                strHTML += "\n    </x:ExcelWorksheet> ";
                strHTML += "\n    <x:ExcelWorksheet> ";
                strHTML += "\n     <x:Name>Sheet3</x:Name> ";
                strHTML += "\n     <x:WorksheetOptions> ";
                strHTML += "\n      <x:ProtectContents>False</x:ProtectContents> ";
                strHTML += "\n      <x:ProtectObjects>False</x:ProtectObjects> ";
                strHTML += "\n      <x:ProtectScenarios>False</x:ProtectScenarios> ";
                strHTML += "\n     </x:WorksheetOptions> ";
                strHTML += "\n    </x:ExcelWorksheet> ";
                strHTML += "\n   </x:ExcelWorksheets> ";
                strHTML += "\n   <x:WindowHeight>9300</x:WindowHeight> ";
                strHTML += "\n   <x:WindowWidth>15135</x:WindowWidth> ";
                strHTML += "\n   <x:WindowTopX>120</x:WindowTopX> ";
                strHTML += "\n   <x:WindowTopY>120</x:WindowTopY> ";
                strHTML += "\n   <x:AcceptLabelsInFormulas/> ";
                strHTML += "\n   <x:ProtectStructure>False</x:ProtectStructure> ";
                strHTML += "\n   <x:ProtectWindows>False</x:ProtectWindows> ";
                strHTML += "\n  </x:ExcelWorkbook> ";
                strHTML += "\n </xml><![endif]--> ";
                strHTML += "\n </head> ";
                strHTML += "\n 	<body>";
                strHTML += this.ltrTable.Text.Trim();
                strHTML += "\n</body> ";
                strHTML += "\n </html> ";

                return strHTML;
            }
            catch
            {
                return "";
            }
        }
        public void SaveExcel(string html, string strNamFile)
        {
            Response.Cache.SetExpires(DateTime.Now.AddSeconds(1));
            Response.Clear();
            Response.AppendHeader("content-disposition", "attachment;filename=" + strNamFile);
            Response.Charset = "";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = "application/vnd.ms-excel";
            this.EnableViewState = false;
            Response.Write("\r\n");
            Response.Write(html);
            Response.End();
        }
        #endregion
        
    #endregion
    #region "Events handle"
        private void loadDataAccess()
        {
            SqlConnection sqlConnec = ConnectData.getConnection();
            objHocVienLV2 = new DAHocVienLV2(sqlConnec);
            objHocVienLV3LV5 = new DAHocVienLV3LV5(sqlConnec);
            objHocVienLV6LV8 = new DAHocVienLV6LV8(sqlConnec);
            objHocVien = new DAHocVien(sqlConnec);
            objNguoidung = new DANguoidung(sqlConnec);
            objTrangThaiGoi = new DATrangThaiGoi(sqlConnec);
            objTrangThai = new DATrangThai(sqlConnec);
            objLevel = new DALevel(sqlConnec);
            objQuyen = new DAQuyen(sqlConnec);
            objReport = new DAReport(sqlConnec);
            objNguon = new DANguon(sqlConnec);
            objTruong = new DATruong(sqlConnec);
            intTrangThaiGoi1 = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["TrangThai1"].ToString());
            intTrangThaiGoi2 = System.Configuration.ConfigurationManager.AppSettings["TrangThai2"].ToString();
            intTrangThaiGoi3 = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["TrangThai3"].ToString());
        }

        private void loadNguon()
        {
            DataSet dsNguon = objNguon.LayDanhSachNguon();
            BindData.bindDropDownList(this.ddlNguon, dsNguon, "ID", "Ten");
        }
        private void loadTruong()
        {
            DataSet dsTruong = objTruong.LayDanhSachTruong();
            BindData.bindDropDownList(this.ddlTruong, dsTruong, "ID", "Ten");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            loadDataAccess();
            if (!this.Page.IsPostBack)
            {
                loadNguon();
                loadTruong();
                int intNguonID = Convert.ToInt32(this.ddlNguon.SelectedValue);
                int intTruongID = Convert.ToInt32(this.ddlTruong.SelectedValue);
                loadHistoryDate(intNguonID,intTruongID);
                //loadHistoryDate(intTruongID);
                this.btnFinished.Visible = false;
                this.btnExportFile.Visible = false;
            }
        }
        //Bao cao
        protected void btnReport23_Click(object sender, EventArgs e)
        {
            int intNguonID = Convert.ToInt32(this.ddlNguon.SelectedValue);
            int intTruongID = Convert.ToInt32(this.ddlTruong.SelectedValue);
            this.btnFinished.Visible = true;
            this.btnExportFile.Visible = true;
            //Lay du lieu cho trang bao cao dau
            this.lblMess.Text = "";
            DateTime dtHistDate;
            string strStarDate = "";
            string strDate = "";
            try
            {
                strDate = this.ddlHistory.SelectedValue.ToString().Trim();
                dtHistDate = Convert.ToDateTime(strDate);
                strDate = dtHistDate.ToString("dd/MM/yyyy").Trim();
            }
            catch
            {
                if (this.ddlHistory.Items.Count > 0)
                {
                    strDate = this.ddlHistory.SelectedItem.Text.ToString().Trim();
                    dtHistDate = Convert.ToDateTime(strDate);
                }
                else
                {
                    strDate ="1/1/1900";
                    dtHistDate = Convert.ToDateTime(strDate);
                }
            }
            m_dtDataReport1 = new DataTable();
            m_dtDataReport1 = objReport.getDataHistoryByDate23S(dtHistDate);
            if (m_dtDataReport1 != null && m_dtDataReport1.Rows.Count > 0)
            {
                if (this.ddlHistory.Items.Count > 0)
                {
                    DateTime dtStarDate = Convert.ToDateTime(m_dtDataReport1.Rows[0]["Date"].ToString());
                    strStarDate = dtHistDate.ToString("dd/MM/yyyy");

                    string strTable = "<table border='0' cellpadding='2' cellspacing='0' style='width:100%;'  >";
                    strTable += "\n<tr>";
                    strTable += "\n<td align='center' class='cssReport23Title1'>Số liệu tính đến: " + strStarDate + "</td>";
                    strTable += "\n<td align='center' class='cssReport23Title1'>Số liệu tính đến: " + txtDate.SelectedDate.ToString("dd/MM/yyyy") + "</td>";
                    strTable += "\n<td align='center' class='cssReport23Title1'>SL làm được từ " + strStarDate + " đến " + txtDate.SelectedDate.ToString("dd/MM/yyyy") + "</td>";
                    strTable += "\n</tr>";
                    strTable += "\n<tr>";
                    strTable += "\n<td valign='top' class='cssReport23Title2'>";
                    loadReportbyTbReportS23Truong(ref strTable, intNguonID,intTruongID);
                    strTable += "\n</td>";
                    strTable += "\n<td valign='top' class='cssReport23Title2'>";
                    loadReportbyTbHocVien(ref strTable, intNguonID,intTruongID);
                    strTable += "\n</td>";
                    strTable += "\n<td valign='top' class='cssReport23Title2'>";
                    loadReportTotal(ref strTable, intNguonID,intTruongID);
                    strTable += "\n</td>";
                    strTable += "\n</tr>";
                    strTable += "\n</table>";
                    ltrTable.Text = strTable;
                }
            }
            else
            {
                   // dtHistDate = Convert.ToDateTime(this.ddlHistory.SelectedValue);
                    //DateTime dtStarDate = Convert.ToDateTime(m_dtDataReport1.Rows[0]["Date"].ToString());
                    strStarDate = dtHistDate.ToString("dd/MM/yyyy");

                    string strTable = "<table border='0' cellpadding='2' cellspacing='0' style='width:100%;'  >";
                    strTable += "\n<tr>";
                    strTable += "\n<td align='center' class='cssReport23Title1'>Số liệu tính đến" + strStarDate + "</td>";
                    strTable += "\n<td align='center' class='cssReport23Title1'>Số liệu tính đến" + DateTime.Now.ToString("dd/MM/yyyy") + "</td>";
                    strTable += "\n<td align='center' class='cssReport23Title1'>SL làm được từ " + strStarDate + " đến " + DateTime.Now.ToString("dd/MM/yyyy") + "</td>";
                    strTable += "\n</tr>";
                    strTable += "\n<tr>";
                    strTable += "\n<td valign='top' class='cssReport23Title2'>";
                    loadReportbyTbReportS23Truong(ref strTable, intNguonID,intTruongID);
                    strTable += "\n</td>";
                    strTable += "\n<td valign='top' class='cssReport23Title2'>";
                    loadReportbyTbHocVien(ref strTable, intNguonID,intTruongID);
                    strTable += "\n</td>";
                    strTable += "\n<td valign='top' class='cssReport23Title2'>";
                    loadReportTotal(ref strTable, intNguonID,intTruongID);
                    strTable += "\n</td>";
                    strTable += "\n</tr>";
                    strTable += "\n</table>";
                    ltrTable.Text = strTable;
            }
        }
        //Luu vao bang ReportS23Truong
        protected void btnFinished_Click(object sender, EventArgs e)
        {
            int intNguonID = Convert.ToInt32(this.ddlNguon.SelectedValue);
            int intTruongID = Convert.ToInt32(this.ddlTruong.SelectedValue);
            SqlConnection sqlConnec = ConnectData.getConnection();
            if (sqlConnec.State != ConnectionState.Open)
            {
                sqlConnec.Open();
            }
            SqlTransaction sqlTransaction = sqlConnec.BeginTransaction();
            try
            {
                int intQuyenID = 4;
                DataSet dsNguoiDung = objNguoidung.loadQuyenNguoiDungByQuyen(intQuyenID, 1);
                if (dsNguoiDung != null)
                {
                    DateTime dateFirstMoth = DateTime.Today;//Convert.ToDateTime(this.txtEndDate.Text.Trim());
                    DataRow[] drNguoiDungV = dsNguoiDung.Tables[0].Select("ID <> 1");
                    foreach (DataRow dr in drNguoiDungV)
                    {
                        int intNguoiDungID = Convert.ToInt32(dr["ID"].ToString());
                        DataSet dsNguoiDungCapDuoi = objNguoidung.loadQuyenNguoiDungCapDuoiByNguoiDung(intNguoiDungID);
                        if (dsNguoiDungCapDuoi != null && dsNguoiDungCapDuoi.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow drNguoiDungCapDuoi in dsNguoiDungCapDuoi.Tables[0].Rows)
                            {
                                int intNguoiDungCapduoi=Convert.ToInt32(drNguoiDungCapDuoi["ID"].ToString());
                                int intL1 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungCapduoi, 1, intNguonID,intTruongID);
                                int intL2 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungCapduoi, 2, intNguonID, intTruongID);
                                int intL3 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungCapduoi, 3, intNguonID, intTruongID);
                                int intL4 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungCapduoi, 4, intNguonID, intTruongID);
                                int intL5A = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungCapduoi, 5, intNguonID, intTruongID);
                                int intL5B = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungCapduoi, 6, intNguonID, intTruongID);
                                int intL6 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungCapduoi, 7, intNguonID, intTruongID);
                                int intL7 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungCapduoi, 8, intNguonID, intTruongID);
                                int intL8 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungCapduoi, 9, intNguonID, intTruongID);
                                int intL9 = objHocVien.loadDemSoHocVienTheoNguoiDung(intNguoiDungCapduoi, 10, intNguonID, intTruongID);
                                ///Get tong L1
                                int intTotalLv1 = intL1 + intL2 + intL3 + intL4 + intL5A + intL5B + intL6 + intL7 + intL8 + intL9;
                                ///Lay Lx1, Lx2, Lx3 voi Level1
                                int intLx1L1 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 1, intTrangThaiGoi1, intNguonID, intTruongID);
                                int intLx3L1 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 1, intTrangThaiGoi3, intNguonID, intTruongID);
                                int intLx2L1 = intL1 - intLx1L1 - intLx3L1;
                                objReport.insertReportS23STruong(intNguoiDungCapduoi, intTotalLv1, intLx1L1, intLx2L1, intLx3L1, 1, dateFirstMoth, sqlTransaction, intNguonID, intTruongID);
                                ///Get tong L2
                                int intTotalLv2 = intTotalLv1 - intL1;
                                ///Lay Lx1, Lx2, Lx3 voi Level2
                                int intLx1L2 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 2, intTrangThaiGoi1, intNguonID, intTruongID);
                                int intLx3L2 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 2, intTrangThaiGoi3, intNguonID, intTruongID);
                                int intLx2L2 = intL2 - intLx1L2 - intLx3L2;

                                objReport.insertReportS23STruong(intNguoiDungCapduoi, intTotalLv2, intLx1L2, intLx2L2, intLx3L2, 2, dateFirstMoth, sqlTransaction, intNguonID, intTruongID);

                                //Tong LV3
                                int intTotalLv3 = intTotalLv2 - intL2;
                                ///Lay Lx1, Lx2, Lx3 voi Level3
                                int intLx1L3 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 3, intTrangThaiGoi1, intNguonID, intTruongID);
                                int intLx3L3 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 3, intTrangThaiGoi3, intNguonID, intTruongID);
                                int intLx2L3 = intL3 - intLx1L3 - intLx3L3;

                                objReport.insertReportS23STruong(intNguoiDungCapduoi, intTotalLv3, intLx1L3, intLx2L3, intLx3L3, 3, dateFirstMoth, sqlTransaction, intNguonID, intTruongID);

                                //Tong LV4
                                int intTotalLv4 = intTotalLv3 - intL3;
                                ///Lay Lx1, Lx2, Lx3 voi Level3
                                int intLx1L4 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 4, intTrangThaiGoi1, intNguonID, intTruongID);
                                int intLx3L4 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 4, intTrangThaiGoi3, intNguonID, intTruongID);
                                int intLx2L4 = intL4 - intLx1L4 - intLx3L4;

                                objReport.insertReportS23STruong(intNguoiDungCapduoi, intTotalLv4, intLx1L4, intLx2L4, intLx3L4, 4, dateFirstMoth, sqlTransaction, intNguonID, intTruongID);

                                //Tong LV5A
                                int intTotalLv5A = intTotalLv4 - intL4;
                                ///Lay Lx1, Lx2, Lx3 voi Level3
                                int intLx1L5a = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 5, intTrangThaiGoi1, intNguonID, intTruongID);
                                int intLx3L5a = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 5, intTrangThaiGoi3, intNguonID, intTruongID);
                                int intLx2L5a = intL5A - intLx1L5a - intLx3L5a;

                                objReport.insertReportS23STruong(intNguoiDungCapduoi, intTotalLv5A, intLx1L5a, intLx2L5a, intLx3L5a, 5, dateFirstMoth, sqlTransaction, intNguonID, intTruongID);
                                //Tong LV5B
                                int intTotalLv5B = intTotalLv5A - intL5A;
                                ///Lay Lx1, Lx2, Lx3 voi Level3
                                int intLx1L5b = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 6, intTrangThaiGoi1, intNguonID, intTruongID);
                                int intLx3L5b = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 6, intTrangThaiGoi3, intNguonID, intTruongID);
                                int intLx2L5b = intL5B - intLx1L5b - intLx3L5b;

                                objReport.insertReportS23STruong(intNguoiDungCapduoi, intTotalLv5B, intLx1L5b, intLx2L5b, intLx3L5b, 6, dateFirstMoth, sqlTransaction, intNguonID, intTruongID);
                                //Tong LV6
                                int intTotalLv6 = intTotalLv5B - intL5B;
                                ///Lay Lx1, Lx2, Lx3 voi Level3
                                int intLx1L6 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 7, intTrangThaiGoi1, intNguonID, intTruongID);
                                int intLx3L6 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 7, intTrangThaiGoi3, intNguonID, intTruongID);
                                int intLx2L6 = intL6 - intLx1L6 - intLx3L6;

                                objReport.insertReportS23STruong(intNguoiDungCapduoi, intTotalLv6, intLx1L6, intLx2L6, intLx3L6, 7, dateFirstMoth, sqlTransaction, intNguonID, intTruongID);
                                //Tong LV7
                                int intTotalLv7 = intTotalLv6 - intL6;
                                ///Lay Lx1, Lx2, Lx3 voi Level7
                                int intLx1L7 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 8, intTrangThaiGoi1, intNguonID, intTruongID);
                                int intLx3L7 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 8, intTrangThaiGoi3, intNguonID, intTruongID);
                                int intLx2L7 = intL7 - intLx1L7 - intLx3L7;

                                objReport.insertReportS23STruong(intNguoiDungCapduoi, intTotalLv7, intLx1L7, intLx2L7, intLx3L7, 8, dateFirstMoth, sqlTransaction, intNguonID, intTruongID);
                                //Tong LV8
                                int intTotalLv8 = intTotalLv7 - intL7;
                                ///Lay Lx1, Lx2, Lx3 voi Level8
                                int intLx1L8 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 9, intTrangThaiGoi1, intNguonID, intTruongID);
                                int intLx3L8 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungCapduoi, 9, intTrangThaiGoi3, intNguonID, intTruongID);
                                int intLx2L8 = intL8 - intLx1L8 - intLx3L8;

                                objReport.insertReportS23STruong(intNguoiDungCapduoi, intTotalLv8, intLx1L8, intLx2L8, intLx3L8, 9, dateFirstMoth, sqlTransaction, intNguonID, intTruongID);
                                //Tong LV9
                                int intTotalLv9 = intTotalLv8 - intL8;
                               // Lay Lx1, Lx2, Lx3 voi Level9
                                int intLx1L9 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 10, intTrangThaiGoi1, intNguonID, intTruongID);
                                int intLx3L9 = objHocVien.loadDemSoHocVienTheoThaiGoiByLevel(intNguoiDungID, 10, intTrangThaiGoi3, intNguonID, intTruongID);
                                int intLx2L9 = intL9 - intLx1L9 - intLx3L9;
                                objReport.insertReportS23STruong(intNguoiDungID, intTotalLv9, intLx1L9, intLx2L9, intLx3L9, 10, dateFirstMoth, sqlTransaction, intNguonID, intTruongID);
                            }
                        }
                    }
                    Response.Write("<script>alert('Lưu thành công bản ghi!');</script>");
                    loadHistoryDate(intNguonID,intTruongID);
                }
                sqlTransaction.Commit();
            }
            catch (Exception ex)
            {
                sqlTransaction.Rollback();
            }
        }
        protected void btnExportFile_Click(object sender, EventArgs e)
        {
            SaveExcel(loadExportReport23STruong(), "Baocaotonghop23_" + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + ".xls");
        }
    #endregion
}